-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1698 from internetee/add-tara-to-registrant
Expand TARA auth logic to registrant portal
- Loading branch information
Showing
22 changed files
with
158 additions
and
401 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module Sso | ||
class TaraController < ApplicationController | ||
skip_authorization_check | ||
|
||
def registrant_callback | ||
user = RegistrantUser.find_or_create_by_omniauth_data(user_hash) | ||
callback(user, registrar: false) | ||
end | ||
|
||
def registrar_callback | ||
user = ApiUser.from_omniauth(user_hash) | ||
callback(user, registrar: true) | ||
end | ||
|
||
# rubocop:disable Style/AndOr | ||
def callback(user, registrar: true) | ||
session[:omniauth_hash] = user_hash | ||
(show_error(registrar: registrar) and return) unless user | ||
|
||
flash[:notice] = t(:signed_in_successfully) | ||
sign_in_and_redirect(registrar ? :registrar_user : :registrant_user, user) | ||
end | ||
# rubocop:enable Style/AndOr | ||
|
||
def cancel | ||
redirect_to root_path, notice: t(:sign_in_cancelled) | ||
end | ||
|
||
def show_error(registrar: true) | ||
path = registrar ? new_registrar_user_session_url : new_registrant_user_session_url | ||
redirect_to path, alert: t(:no_such_user) | ||
end | ||
|
||
private | ||
|
||
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 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 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 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
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
Oops, something went wrong.