mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 23:24:48 +02:00
Expand TARA auth flow to registrant portal
This commit is contained in:
parent
248c984443
commit
04f0ef9a93
7 changed files with 85 additions and 27 deletions
33
app/controllers/registrant/tara_controller.rb
Normal file
33
app/controllers/registrant/tara_controller.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
class Registrant
|
||||
class TaraController < ApplicationController
|
||||
skip_authorization_check
|
||||
|
||||
# rubocop:disable Style/AndOr
|
||||
def callback
|
||||
session[:omniauth_hash] = user_hash
|
||||
@registrant_user = RegistrantUser.find_or_create_by_omniauth_data(user_hash)
|
||||
|
||||
if @registrant_user
|
||||
flash[:notice] = t(:signed_in_successfully)
|
||||
sign_in_and_redirect(:registrant_user, @registrant_user)
|
||||
else
|
||||
show_error and return
|
||||
end
|
||||
end
|
||||
# rubocop:enable Style/AndOr
|
||||
|
||||
def cancel
|
||||
redirect_to root_path, notice: t(:sign_in_cancelled)
|
||||
end
|
||||
|
||||
def show_error
|
||||
redirect_to new_registrant_user_session_url, alert: t(:no_such_user)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def user_hash
|
||||
request.env['omniauth.auth']
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue