Commit 7a139c16 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Add username to terms message in git and API calls

This will make it clearer to users which account is being used to make
the API/git call. So they know which account needs to be used to
accept the terms.

Closes #46649
parent c52db71e
---
title: Add username to terms message in git and API calls
merge_request: 19126
author:
type: changed
...@@ -8,12 +8,12 @@ module Gitlab ...@@ -8,12 +8,12 @@ module Gitlab
def rejection_message def rejection_message
case rejection_type case rejection_type
when :internal when :internal
'This action cannot be performed by internal users' "This action cannot be performed by internal users"
when :terms_not_accepted when :terms_not_accepted
'You must accept the Terms of Service in order to perform this action. '\ "You (#{@user.to_reference}) must accept the Terms of Service in order to perform this action. "\
'Please access GitLab from a web browser to accept these terms.' "Please access GitLab from a web browser to accept these terms."
else else
'Your account has been blocked.' "Your account has been blocked."
end end
end end
......
...@@ -22,7 +22,8 @@ describe Gitlab::Auth::UserAccessDeniedReason do ...@@ -22,7 +22,8 @@ describe Gitlab::Auth::UserAccessDeniedReason do
enforce_terms enforce_terms
end end
it { is_expected.to match /You must accept the Terms of Service/ } it { is_expected.to match /must accept the Terms of Service/ }
it { is_expected.to include(user.username) }
end end
context 'when the user is internal' do context 'when the user is internal' do
......
...@@ -1055,7 +1055,7 @@ describe Gitlab::GitAccess do ...@@ -1055,7 +1055,7 @@ describe Gitlab::GitAccess do
it 'blocks access when the user did not accept terms', :aggregate_failures do it 'blocks access when the user did not accept terms', :aggregate_failures do
actions.each do |action| actions.each do |action|
expect { action.call }.to raise_unauthorized(/You must accept the Terms of Service in order to perform this action/) expect { action.call }.to raise_unauthorized(/must accept the Terms of Service in order to perform this action/)
end end
end end
......
...@@ -171,7 +171,7 @@ describe API::Helpers do ...@@ -171,7 +171,7 @@ describe API::Helpers do
end end
it 'returns a 403 when a user has not accepted the terms' do it 'returns a 403 when a user has not accepted the terms' do
expect { current_user }.to raise_error /You must accept the Terms of Service/ expect { current_user }.to raise_error /must accept the Terms of Service/
end end
it 'sets the current user when the user accepted the terms' do it 'sets the current user when the user accepted the terms' do
......
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