From 42488b4ee87c356459d7cb49945df42d013afe81 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 30 Sep 2020 15:43:55 +0500 Subject: [PATCH] Add error if no API user found --- app/controllers/registrar/tara_controller.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/controllers/registrar/tara_controller.rb b/app/controllers/registrar/tara_controller.rb index 9107e46ce..84938a777 100644 --- a/app/controllers/registrar/tara_controller.rb +++ b/app/controllers/registrar/tara_controller.rb @@ -2,19 +2,27 @@ class Registrar class TaraController < ApplicationController skip_authorization_check + # rubocop:disable Style/AndOr def callback session[:omniauth_hash] = user_hash @api_user = ApiUser.from_omniauth(user_hash) - return unless @api_user - - sign_in_and_redirect(:registrar_user, @api_user) + if @api_user + sign_in_and_redirect(:registrar_user, @api_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_registrar_user_session_url, alert: t(:no_such_user) + end + private def user_hash