BigW Consortium Gitlab

Add an oauth provider path helper.

The helper constructs the path for a given oauth provider since Devise 4.0 deprecated passing the provider to the omniauth authentication path. Fixes #18110.
parent bbb044e1
...@@ -101,7 +101,7 @@ class SessionsController < Devise::SessionsController ...@@ -101,7 +101,7 @@ class SessionsController < Devise::SessionsController
# Prevent alert from popping up on the first page shown after authentication. # Prevent alert from popping up on the first page shown after authentication.
flash[:alert] = nil flash[:alert] = nil
redirect_to user_omniauth_authorize_path(provider.to_sym) redirect_to provider_path(provider)
end end
def valid_otp_attempt?(user) def valid_otp_attempt?(user)
......
...@@ -60,6 +60,12 @@ module AuthHelper ...@@ -60,6 +60,12 @@ module AuthHelper
end end
end end
# Constructs the OAuth provider path.
# For example: user_google_omniauth_authorize_path
def provider_path(provider)
send("user_#{provider.underscore}_omniauth_authorize_path")
end
def auth_active?(provider) def auth_active?(provider)
current_user.identities.exists?(provider: provider.to_s) current_user.identities.exists?(provider: provider.to_s)
end end
......
= form_tag(user_omniauth_authorize_path("crowd"), id: 'new_crowd_user' ) do = form_tag(provider_path("crowd"), id: 'new_crowd_user' ) do
= text_field_tag :username, nil, {class: "form-control top", placeholder: "Username", autofocus: "autofocus"} = text_field_tag :username, nil, {class: "form-control top", placeholder: "Username", autofocus: "autofocus"}
= password_field_tag :password, nil, {class: "form-control bottom", placeholder: "Password"} = password_field_tag :password, nil, {class: "form-control bottom", placeholder: "Password"}
- if devise_mapping.rememberable? - if devise_mapping.rememberable?
......
...@@ -5,4 +5,4 @@ ...@@ -5,4 +5,4 @@
- providers.each do |provider| - providers.each do |provider|
%span.light %span.light
- has_icon = provider_has_icon?(provider) - has_icon = provider_has_icon?(provider)
= link_to provider_image_tag(provider), user_omniauth_authorize_path(provider), method: :post, class: (has_icon ? 'oauth-image-link' : 'btn'), "data-no-turbolink" => "true" = link_to provider_image_tag(provider), provider_path(provider), method: :post, class: (has_icon ? 'oauth-image-link' : 'btn'), "data-no-turbolink" => "true"
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
= link_to unlink_profile_account_path(provider: provider), method: :delete, class: 'provider-btn' do = link_to unlink_profile_account_path(provider: provider), method: :delete, class: 'provider-btn' do
Disconnect Disconnect
- else - else
= link_to user_omniauth_authorize_path(provider), method: :post, class: 'provider-btn not-active', "data-no-turbolink" => "true" do = link_to provider_path(provider), method: :post, class: 'provider-btn not-active', "data-no-turbolink" => "true" do
Connect Connect
%hr %hr
- if current_user.can_change_username? - if current_user.can_change_username?
......
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