diff options
author | Jan-Willem van der Meer <mail@jewilmeer.nl> | 2014-10-16 22:08:30 +0400 |
---|---|---|
committer | Jan-Willem van der Meer <mail@jewilmeer.nl> | 2014-10-16 22:08:30 +0400 |
commit | d9bfebc0e87ef426aea7eb4fdd1338f04b106354 (patch) | |
tree | 94727a80af60c0c55c9fcf38250bbd4fd762da13 /app/controllers | |
parent | fad588f2bee102bf4ab090874d041e227d4e2ee4 (diff) |
Add regressiontest to verify allow_single_sign_on setting
verification for #1677
Since testing omniauth_callback_controller.rb is very difficult, the logic
is moved to the models
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/omniauth_callbacks_controller.rb | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 589f8387b03..58d1e37f655 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -49,22 +49,19 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController redirect_to profile_path else @user = Gitlab::OAuth::User.new(oauth) - - if Gitlab.config.omniauth['allow_single_sign_on'] && @user.new? - @user.save - end + @user.save # Only allow properly saved users to login. if @user.persisted? && @user.valid? sign_in_and_redirect(@user.gl_user) - elsif @user.gl_user.errors.any? + else @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 + rescue StandardError + flash[:notice] = "There's no such user!" + redirect_to new_user_session_path end def oauth |