Commit de253100 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'issue-respect-single-sign-on' into 'master'

Issue respect single sign on

Fixes #1677 by making sure the per-build user is saved as well. Otherwise the user is passed to devise, and the user is saved afterwards, creating a successful signup.

See merge request !1186
parents 05922e71 92c184a5
...@@ -54,11 +54,15 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -54,11 +54,15 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
@user.save @user.save
end end
if @user.valid? # Only allow properly saved users to login.
if @user.persisted? && @user.valid?
sign_in_and_redirect(@user.gl_user) 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(", ") error_message = @user.gl_user.errors.map{ |attribute, message| "#{attribute} #{message}" }.join(", ")
redirect_to omniauth_error_path(oauth['provider'], error: error_message) and return 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 end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment