summaryrefslogtreecommitdiff
path: root/app/controllers/omniauth_callbacks_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/omniauth_callbacks_controller.rb')
-rw-r--r--app/controllers/omniauth_callbacks_controller.rb40
1 files changed, 20 insertions, 20 deletions
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb
index cc2bb99f55b..eda404acce7 100644
--- a/app/controllers/omniauth_callbacks_controller.rb
+++ b/app/controllers/omniauth_callbacks_controller.rb
@@ -34,7 +34,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
error ||= exception.message if exception.respond_to?(:message)
error ||= request.env["omniauth.error.type"].to_s
- error.to_s.humanize if error
+ error&.to_s&.humanize
end
def saml
@@ -44,28 +44,28 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def omniauth_error
@provider = params[:provider]
@error = params[:error]
- render 'errors/omniauth_error', layout: "oauth_error", status: 422
+ render "errors/omniauth_error", layout: "oauth_error", status: 422
end
def cas3
- ticket = params['ticket']
+ ticket = params["ticket"]
if ticket
- handle_service_ticket oauth['provider'], ticket
+ handle_service_ticket oauth["provider"], ticket
end
handle_omniauth
end
def authentiq
- if params['sid']
- handle_service_ticket oauth['provider'], params['sid']
+ if params["sid"]
+ handle_service_ticket oauth["provider"], params["sid"]
end
handle_omniauth
end
def auth0
- if oauth['uid'].blank?
+ if oauth["uid"].blank?
fail_auth0_login
else
handle_omniauth
@@ -75,12 +75,12 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
private
def omniauth_flow(auth_module, identity_linker: nil)
- if fragment = request.env.dig('omniauth.params', 'redirect_fragment').presence
+ if fragment = request.env.dig("omniauth.params", "redirect_fragment").presence
store_redirect_fragment(fragment)
end
if current_user
- log_audit_event(current_user, with: oauth['provider'])
+ log_audit_event(current_user, with: oauth["provider"])
identity_linker ||= auth_module::IdentityLinker.new(current_user, oauth)
@@ -107,7 +107,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
end
def redirect_identity_linked
- redirect_to profile_account_path, notice: 'Authentication method updated'
+ redirect_to profile_account_path, notice: "Authentication method updated"
end
def handle_service_ticket(provider, ticket)
@@ -125,7 +125,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
user = auth_user.find_and_update!
if auth_user.valid_sign_in?
- log_audit_event(user, with: oauth['provider'])
+ log_audit_event(user, with: oauth["provider"])
set_remember_me(user)
@@ -144,35 +144,35 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
end
def handle_signup_error
- label = Gitlab::Auth::OAuth::Provider.label_for(oauth['provider'])
+ label = Gitlab::Auth::OAuth::Provider.label_for(oauth["provider"])
message = ["Signing in using your #{label} account without a pre-existing GitLab account is not allowed."]
if Gitlab::CurrentSettings.allow_signup?
message << "Create a GitLab account first, and then connect it to your #{label} account."
end
- flash[:notice] = message.join(' ')
+ flash[:notice] = message.join(" ")
redirect_to new_user_session_path
end
def oauth
- @oauth ||= request.env['omniauth.auth']
+ @oauth ||= request.env["omniauth.auth"]
end
def fail_login(user)
error_message = user.errors.full_messages.to_sentence
- return redirect_to omniauth_error_path(oauth['provider'], error: error_message)
+ redirect_to omniauth_error_path(oauth["provider"], error: error_message)
end
def fail_auth0_login
- flash[:alert] = 'Wrong extern UID provided. Make sure Auth0 is configured correctly.'
+ flash[:alert] = "Wrong extern UID provided. Make sure Auth0 is configured correctly."
redirect_to new_user_session_path
end
def handle_disabled_provider
- label = Gitlab::Auth::OAuth::Provider.label_for(oauth['provider'])
+ label = Gitlab::Auth::OAuth::Provider.label_for(oauth["provider"])
flash[:alert] = "Signing in using #{label} has been disabled"
redirect_to new_user_session_path
@@ -187,15 +187,15 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
return unless remember_me?
if user.two_factor_enabled?
- params[:remember_me] = '1'
+ params[:remember_me] = "1"
else
remember_me(user)
end
end
def remember_me?
- request_params = request.env['omniauth.params']
- (request_params['remember_me'] == '1') if request_params.present?
+ request_params = request.env["omniauth.params"]
+ (request_params["remember_me"] == "1") if request_params.present?
end
def store_redirect_fragment(redirect_fragment)