summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/omniauth_callbacks_controller.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb
index f46b36568f3..589f8387b03 100644
--- a/app/controllers/omniauth_callbacks_controller.rb
+++ b/app/controllers/omniauth_callbacks_controller.rb
@@ -54,11 +54,15 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
@user.save
end
- if @user.valid?
+ # Only allow properly saved users to login.
+ if @user.persisted? && @user.valid?
sign_in_and_redirect(@user.gl_user)
- else
+ elsif @user.gl_user.errors.any?
error_message = @user.gl_user.errors.map{ |attribute, message| "#{attribute} #{message}" }.join(", ")
redirect_to omniauth_error_path(oauth['provider'], error: error_message) and return
+ else
+ flash[:notice] = "There's no such user!"
+ redirect_to new_user_session_path
end
end
end