Commit 1edf8183 authored by Peter Hegman's avatar Peter Hegman Committed by Pavel Shutsin

Update no password message shown when logged in via OAuth

parent 6e016e25
...@@ -23,14 +23,14 @@ export default class Project { ...@@ -23,14 +23,14 @@ export default class Project {
}); });
} }
$('.hide-no-ssh-message').on('click', function (e) { $('.js-hide-no-ssh-message').on('click', function (e) {
Cookies.set('hide_no_ssh_message', 'false'); Cookies.set('hide_no_ssh_message', 'false');
$(this).parents('.no-ssh-key-message').remove(); $(this).parents('.js-no-ssh-key-message').remove();
return e.preventDefault(); return e.preventDefault();
}); });
$('.hide-no-password-message').on('click', function (e) { $('.js-hide-no-password-message').on('click', function (e) {
Cookies.set('hide_no_password_message', 'false'); Cookies.set('hide_no_password_message', 'false');
$(this).parents('.no-password-message').remove(); $(this).parents('.js-no-password-message').remove();
return e.preventDefault(); return e.preventDefault();
}); });
$('.hide-auto-devops-implicitly-enabled-banner').on('click', function (e) { $('.hide-auto-devops-implicitly-enabled-banner').on('click', function (e) {
......
...@@ -196,12 +196,26 @@ module ProjectsHelper ...@@ -196,12 +196,26 @@ module ProjectsHelper
cookies["hide_auto_devops_implicitly_enabled_banner_#{project.id}".to_sym].blank? cookies["hide_auto_devops_implicitly_enabled_banner_#{project.id}".to_sym].blank?
end end
def link_to_set_password def no_password_message
if current_user.require_password_creation_for_git? push_pull_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: help_page_path('gitlab-basics/start-using-git', anchor: 'pull-and-push') }
link_to s_('SetPasswordToCloneLink|set a password'), edit_profile_password_path clone_with_https_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: help_page_path('gitlab-basics/start-using-git', anchor: 'clone-with-https') }
else set_password_link_start = '<a href="%{url}">'.html_safe % { url: edit_profile_password_path }
link_to s_('CreateTokenToCloneLink|create a personal access token'), profile_personal_access_tokens_path set_up_pat_link_start = '<a href="%{url}">'.html_safe % { url: profile_personal_access_tokens_path }
end
message = if current_user.require_password_creation_for_git?
_('Your account is authenticated with SSO or SAML. To %{push_pull_link_start}push and pull%{link_end} over %{protocol} with Git using this account, you must %{set_password_link_start}set a password%{link_end} or %{set_up_pat_link_start}set up a Personal Access Token%{link_end} to use instead of a password. For more information, see %{clone_with_https_link_start}Clone with HTTPS%{link_end}.')
else
_('Your account is authenticated with SSO or SAML. To %{push_pull_link_start}push and pull%{link_end} over %{protocol} with Git using this account, you must %{set_up_pat_link_start}set up a Personal Access Token%{link_end} to use instead of a password. For more information, see %{clone_with_https_link_start}Clone with HTTPS%{link_end}.')
end
html_escape(message) % {
push_pull_link_start: push_pull_link_start,
protocol: gitlab_config.protocol.upcase,
clone_with_https_link_start: clone_with_https_link_start,
set_password_link_start: set_password_link_start,
set_up_pat_link_start: set_up_pat_link_start,
link_end: '</a>'.html_safe
}
end end
# Returns true if any projects are present. # Returns true if any projects are present.
......
- if show_no_password_message? - if show_no_password_message?
.no-password-message.gl-alert.gl-alert-warning = render 'shared/global_alert',
= sprite_icon('warning', size: 16, css_class: 'gl-icon gl-alert-icon gl-alert-icon-no-title') variant: :warning,
%button.js-close.gl-alert-dismiss{ type: 'button', 'aria-label': _('Dismiss') } alert_class: 'js-no-password-message',
= sprite_icon('close', size: 16, css_class: 'gl-icon') close_button_class: 'js-hide-no-password-message' do
.gl-alert-body .gl-alert-body
- translation_params = { protocol: gitlab_config.protocol.upcase, set_password_link: link_to_set_password } = no_password_message
- set_password_message = _("You won't be able to pull or push repositories via %{protocol} until you %{set_password_link} on your account") % translation_params
= set_password_message.html_safe
.gl-alert-actions .gl-alert-actions
= link_to _('Remind later'), '#', class: 'hide-no-password-message btn gl-alert-action btn-info btn-md gl-button' = link_to _('Remind later'), '#', class: 'js-hide-no-password-message gl-alert-action btn btn-confirm btn-md gl-button'
= link_to _("Don't show again"), profile_path(user: {hide_no_password: true}), method: :put, role: 'button', class: 'btn gl-alert-action btn-md btn-default gl-button btn-default-secondary' = link_to _("Don't show again"), profile_path(user: { hide_no_password: true }), method: :put, role: 'button', class: 'gl-alert-action btn btn-default btn-md gl-button'
- if show_no_ssh_key_message? - if show_no_ssh_key_message?
%div{ class: 'no-ssh-key-message gl-alert gl-alert-warning', role: 'alert' } = render 'shared/global_alert',
= sprite_icon('warning', css_class: 'gl-icon s16 gl-alert-icon gl-alert-icon-no-title') variant: :warning,
%button{ class: 'gl-alert-dismiss hide-no-ssh-message', type: 'button', 'aria-label': _('Dismiss') } alert_class: 'js-no-ssh-message',
= sprite_icon('close', css_class: 'gl-icon s16') close_button_class: 'js-hide-no-ssh-message' do
.gl-alert-body .gl-alert-body
= s_("MissingSSHKeyWarningLink|You won't be able to pull or push repositories via SSH until you add an SSH key to your profile") = s_("MissingSSHKeyWarningLink|You can't push or pull repositories using SSH until you add an SSH key to your profile.")
.gl-alert-actions .gl-alert-actions
= link_to s_('MissingSSHKeyWarningLink|Add SSH key'), profile_keys_path, class: "btn gl-alert-action btn-warning btn-md gl-button" = link_to s_('MissingSSHKeyWarningLink|Add SSH key'), profile_keys_path, class: "gl-alert-action btn btn-confirm btn-md gl-button"
= link_to s_("MissingSSHKeyWarningLink|Don't show again"), profile_path(user: {hide_no_ssh_key: true}), method: :put, role: 'button', class: 'btn gl-alert-action btn-md btn-warning gl-button btn-warning-secondary' = link_to s_("MissingSSHKeyWarningLink|Don't show again"), profile_path(user: { hide_no_ssh_key: true }), method: :put, role: 'button', class: 'gl-alert-action btn btn-default btn-md gl-button'
...@@ -9793,9 +9793,6 @@ msgstr "" ...@@ -9793,9 +9793,6 @@ msgstr ""
msgid "CreateTag|Tag" msgid "CreateTag|Tag"
msgstr "" msgstr ""
msgid "CreateTokenToCloneLink|create a personal access token"
msgstr ""
msgid "CreateValueStreamForm|%{name} (default)" msgid "CreateValueStreamForm|%{name} (default)"
msgstr "" msgstr ""
...@@ -22414,6 +22411,9 @@ msgstr "" ...@@ -22414,6 +22411,9 @@ msgstr ""
msgid "MissingSSHKeyWarningLink|Don't show again" msgid "MissingSSHKeyWarningLink|Don't show again"
msgstr "" msgstr ""
msgid "MissingSSHKeyWarningLink|You can't push or pull repositories using SSH until you add an SSH key to your profile."
msgstr ""
msgid "MissingSSHKeyWarningLink|You won't be able to pull or push repositories via SSH until you add an SSH key to your profile" msgid "MissingSSHKeyWarningLink|You won't be able to pull or push repositories via SSH until you add an SSH key to your profile"
msgstr "" msgstr ""
...@@ -31504,9 +31504,6 @@ msgstr "" ...@@ -31504,9 +31504,6 @@ msgstr ""
msgid "Set what should be replicated by this secondary site." msgid "Set what should be replicated by this secondary site."
msgstr "" msgstr ""
msgid "SetPasswordToCloneLink|set a password"
msgstr ""
msgid "SetStatusModal|Add status emoji" msgid "SetStatusModal|Add status emoji"
msgstr "" msgstr ""
...@@ -39582,9 +39579,6 @@ msgstr "" ...@@ -39582,9 +39579,6 @@ msgstr ""
msgid "You won't be able to create new projects because you have reached your project limit." msgid "You won't be able to create new projects because you have reached your project limit."
msgstr "" msgstr ""
msgid "You won't be able to pull or push repositories via %{protocol} until you %{set_password_link} on your account"
msgstr ""
msgid "You'll be charged for %{true_up_link_start}users over license%{link_end} on a quarterly or annual basis, depending on the terms of your agreement." msgid "You'll be charged for %{true_up_link_start}users over license%{link_end} on a quarterly or annual basis, depending on the terms of your agreement."
msgstr "" msgstr ""
...@@ -39735,6 +39729,12 @@ msgstr "" ...@@ -39735,6 +39729,12 @@ msgstr ""
msgid "Your account has been deactivated. You will not be able to: " msgid "Your account has been deactivated. You will not be able to: "
msgstr "" msgstr ""
msgid "Your account is authenticated with SSO or SAML. To %{push_pull_link_start}push and pull%{link_end} over %{protocol} with Git using this account, you must %{set_password_link_start}set a password%{link_end} or %{set_up_pat_link_start}set up a Personal Access Token%{link_end} to use instead of a password. For more information, see %{clone_with_https_link_start}Clone with HTTPS%{link_end}."
msgstr ""
msgid "Your account is authenticated with SSO or SAML. To %{push_pull_link_start}push and pull%{link_end} over %{protocol} with Git using this account, you must %{set_up_pat_link_start}set up a Personal Access Token%{link_end} to use instead of a password. For more information, see %{clone_with_https_link_start}Clone with HTTPS%{link_end}."
msgstr ""
msgid "Your account is locked." msgid "Your account is locked."
msgstr "" msgstr ""
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'No Password Alert' do RSpec.describe 'No Password Alert' do
let_it_be(:message_password_auth_enabled) { 'Your account is authenticated with SSO or SAML. To push and pull over HTTP with Git using this account, you must set a password or set up a Personal Access Token to use instead of a password. For more information, see Clone with HTTPS.' }
let_it_be(:message_password_auth_disabled) { 'Your account is authenticated with SSO or SAML. To push and pull over HTTP with Git using this account, you must set up a Personal Access Token to use instead of a password. For more information, see Clone with HTTPS.' }
let(:project) { create(:project, :repository, namespace: user.namespace) } let(:project) { create(:project, :repository, namespace: user.namespace) }
context 'with internal auth enabled' do context 'with internal auth enabled' do
...@@ -15,7 +18,7 @@ RSpec.describe 'No Password Alert' do ...@@ -15,7 +18,7 @@ RSpec.describe 'No Password Alert' do
let(:user) { create(:user) } let(:user) { create(:user) }
it 'shows no alert' do it 'shows no alert' do
expect(page).not_to have_content "You won't be able to pull or push repositories via HTTP until you set a password on your account" expect(page).not_to have_content message_password_auth_enabled
end end
end end
...@@ -23,7 +26,7 @@ RSpec.describe 'No Password Alert' do ...@@ -23,7 +26,7 @@ RSpec.describe 'No Password Alert' do
let(:user) { create(:user, password_automatically_set: true) } let(:user) { create(:user, password_automatically_set: true) }
it 'shows a password alert' do it 'shows a password alert' do
expect(page).to have_content "You won't be able to pull or push repositories via HTTP until you set a password on your account" expect(page).to have_content message_password_auth_enabled
end end
end end
end end
...@@ -41,7 +44,7 @@ RSpec.describe 'No Password Alert' do ...@@ -41,7 +44,7 @@ RSpec.describe 'No Password Alert' do
gitlab_sign_in_via('saml', user, 'my-uid') gitlab_sign_in_via('saml', user, 'my-uid')
visit project_path(project) visit project_path(project)
expect(page).to have_content "You won't be able to pull or push repositories via HTTP until you create a personal access token on your account" expect(page).to have_content message_password_auth_disabled
end end
end end
...@@ -51,7 +54,7 @@ RSpec.describe 'No Password Alert' do ...@@ -51,7 +54,7 @@ RSpec.describe 'No Password Alert' do
gitlab_sign_in_via('saml', user, 'my-uid') gitlab_sign_in_via('saml', user, 'my-uid')
visit project_path(project) visit project_path(project)
expect(page).not_to have_content "You won't be able to pull or push repositories via HTTP until you create a personal access token on your account" expect(page).not_to have_content message_password_auth_disabled
end end
end end
end end
......
...@@ -268,7 +268,7 @@ RSpec.describe ProjectsHelper do ...@@ -268,7 +268,7 @@ RSpec.describe ProjectsHelper do
end end
end end
describe '#link_to_set_password' do describe '#no_password_message' do
let(:user) { create(:user, password_automatically_set: true) } let(:user) { create(:user, password_automatically_set: true) }
before do before do
...@@ -276,18 +276,18 @@ RSpec.describe ProjectsHelper do ...@@ -276,18 +276,18 @@ RSpec.describe ProjectsHelper do
end end
context 'password authentication is enabled for Git' do context 'password authentication is enabled for Git' do
it 'returns link to set a password' do it 'returns message prompting user to set password or set up a PAT' do
stub_application_setting(password_authentication_enabled_for_git?: true) stub_application_setting(password_authentication_enabled_for_git?: true)
expect(helper.link_to_set_password).to match %r{<a href="#{edit_profile_password_path}">set a password</a>} expect(helper.no_password_message).to eq('Your account is authenticated with SSO or SAML. To <a href="/help/gitlab-basics/start-using-git#pull-and-push" target="_blank" rel="noopener noreferrer">push and pull</a> over HTTP with Git using this account, you must <a href="/-/profile/password/edit">set a password</a> or <a href="/-/profile/personal_access_tokens">set up a Personal Access Token</a> to use instead of a password. For more information, see <a href="/help/gitlab-basics/start-using-git#clone-with-https" target="_blank" rel="noopener noreferrer">Clone with HTTPS</a>.')
end end
end end
context 'password authentication is disabled for Git' do context 'password authentication is disabled for Git' do
it 'returns link to create a personal access token' do it 'returns message prompting user to set up a PAT' do
stub_application_setting(password_authentication_enabled_for_git?: false) stub_application_setting(password_authentication_enabled_for_git?: false)
expect(helper.link_to_set_password).to match %r{<a href="#{profile_personal_access_tokens_path}">create a personal access token</a>} expect(helper.no_password_message).to eq('Your account is authenticated with SSO or SAML. To <a href="/help/gitlab-basics/start-using-git#pull-and-push" target="_blank" rel="noopener noreferrer">push and pull</a> over HTTP with Git using this account, you must <a href="/-/profile/personal_access_tokens">set up a Personal Access Token</a> to use instead of a password. For more information, see <a href="/help/gitlab-basics/start-using-git#clone-with-https" target="_blank" rel="noopener noreferrer">Clone with HTTPS</a>.')
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