-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc93ec2
commit eb156ec
Showing
15 changed files
with
248 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
AllCops: | ||
Exclude: | ||
- 'spec/**/*' | ||
- 'config/**/*' | ||
Style/Documentation: | ||
Enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require 'countries' | ||
|
||
module Auth | ||
class TaraController < ApplicationController | ||
skip_authentication | ||
|
||
before_action :clear_from_credentials, only: :callback | ||
|
||
include TaraAccessable | ||
|
||
rescue_from ActiveRecord::RecordNotFound, with: :no_user | ||
|
||
def callback | ||
if app_session | ||
log_in app_session | ||
|
||
redirect_to root_path, notice: t('.signed_in'), status: :see_other | ||
else | ||
flash.now[:danger] = I18n.t('.incorrect_details') | ||
render 'sessions/new', status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def setup | ||
request.env['omniauth.strategy'].options.merge!(options) | ||
|
||
render plain: 'Omniauth setup phase', status: 404 | ||
end | ||
|
||
def cancel | ||
redirect_to root_path, notice: t(:sign_in_cancelled) | ||
end | ||
|
||
private | ||
|
||
def no_user | ||
render 'sessions/new', status: :unprocessable_entity | ||
end | ||
|
||
def app_session | ||
@app_session ||= if tara_params_initiator == 'registrant' | ||
Registrant::RegistrantAuth.call(tara_params: @user_info) | ||
elsif tara_params_initiator == 'registrar' | ||
Registrar::RegistrarAuth.call(tara_params: @user_info) | ||
end | ||
end | ||
|
||
def clear_from_credentials | ||
@user_info = user_hash.delete_if { |key, _| key == 'credentials' } | ||
end | ||
|
||
def user_hash | ||
request.env['omniauth.auth'] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.