Add error if no API user found

This commit is contained in:
Alex Sherman 2020-09-30 15:43:55 +05:00
parent 96c0d09c07
commit 42488b4ee8

View file

@ -2,19 +2,27 @@ class Registrar
class TaraController < ApplicationController class TaraController < ApplicationController
skip_authorization_check skip_authorization_check
# rubocop:disable Style/AndOr
def callback def callback
session[:omniauth_hash] = user_hash session[:omniauth_hash] = user_hash
@api_user = ApiUser.from_omniauth(user_hash) @api_user = ApiUser.from_omniauth(user_hash)
return unless @api_user if @api_user
sign_in_and_redirect(:registrar_user, @api_user)
sign_in_and_redirect(:registrar_user, @api_user) else
show_error and return
end
end end
# rubocop:enable Style/AndOr
def cancel def cancel
redirect_to root_path, notice: t(:sign_in_cancelled) redirect_to root_path, notice: t(:sign_in_cancelled)
end end
def show_error
redirect_to new_registrar_user_session_url, alert: t(:no_such_user)
end
private private
def user_hash def user_hash