Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-02-19 00:14:53 +0300
committerDouwe Maan <douwe@selenight.nl>2016-02-19 00:14:53 +0300
commit873b0db220b92008ed833f0909ecab8861bf00e8 (patch)
treeb84cb7114af9a4f5c30a8e19342a32e7ec18e42b /app/controllers/omniauth_callbacks_controller.rb
parent6524fbeaba7c16ae8ca514c7540a1aa6e86f4129 (diff)
Revert "Merge branch 'saml-decoupling' into 'master' "
This reverts commit c04e22fba8d130a58f498ff48127712d7dae17ee, reversing changes made to 0feab326d52222dc0ab5bd0a6b15dab297f44aa9.
Diffstat (limited to 'app/controllers/omniauth_callbacks_controller.rb')
-rw-r--r--app/controllers/omniauth_callbacks_controller.rb54
1 files changed, 18 insertions, 36 deletions
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb
index 21135f7d607..9cf76521a0d 100644
--- a/app/controllers/omniauth_callbacks_controller.rb
+++ b/app/controllers/omniauth_callbacks_controller.rb
@@ -42,26 +42,6 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
end
end
- def saml
- if current_user
- log_audit_event(current_user, with: :saml)
- # Update SAML identity if data has changed.
- identity = current_user.identities.find_by(extern_uid: oauth['uid'], provider: :saml)
- if identity.nil?
- current_user.identities.create(extern_uid: oauth['uid'], provider: :saml)
- redirect_to profile_account_path, notice: 'Authentication method updated'
- else
- redirect_to after_sign_in_path_for(current_user)
- end
- else
- saml_user = Gitlab::Saml::User.new(oauth)
- saml_user.save
- @user = saml_user.gl_user
-
- continue_login_process
- end
- end
-
def omniauth_error
@provider = params[:provider]
@error = params[:error]
@@ -85,11 +65,25 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
log_audit_event(current_user, with: oauth['provider'])
redirect_to profile_account_path, notice: 'Authentication method updated'
else
- oauth_user = Gitlab::OAuth::User.new(oauth)
- oauth_user.save
- @user = oauth_user.gl_user
+ @user = Gitlab::OAuth::User.new(oauth)
+ @user.save
- continue_login_process
+ # Only allow properly saved users to login.
+ if @user.persisted? && @user.valid?
+ log_audit_event(@user.gl_user, with: oauth['provider'])
+ sign_in_and_redirect(@user.gl_user)
+ else
+ error_message =
+ if @user.gl_user.errors.any?
+ @user.gl_user.errors.map do |attribute, message|
+ "#{attribute} #{message}"
+ end.join(", ")
+ else
+ ''
+ end
+
+ redirect_to omniauth_error_path(oauth['provider'], error: error_message) and return
+ end
end
rescue Gitlab::OAuth::SignupDisabledError
label = Gitlab::OAuth::Provider.label_for(oauth['provider'])
@@ -110,18 +104,6 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
session[:service_tickets][provider] = ticket
end
- def continue_login_process
- # Only allow properly saved users to login.
- if @user.persisted? && @user.valid?
- log_audit_event(@user, with: oauth['provider'])
- sign_in_and_redirect(@user)
- else
- error_message = @user.errors.full_messages.to_sentence
-
- redirect_to omniauth_error_path(oauth['provider'], error: error_message) and return
- end
- end
-
def oauth
@oauth ||= request.env['omniauth.auth']
end