2018-10-11 16:12:21 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-08 09:07:55 -04:00
|
|
|
module Gitlab
|
|
|
|
module Auth
|
|
|
|
class UserAccessDeniedReason
|
|
|
|
def initialize(user)
|
|
|
|
@user = user
|
|
|
|
end
|
|
|
|
|
|
|
|
def rejection_message
|
|
|
|
case rejection_type
|
|
|
|
when :internal
|
2018-05-24 03:46:30 -04:00
|
|
|
"This action cannot be performed by internal users"
|
2020-10-06 08:08:38 -04:00
|
|
|
when :blocked_pending_approval
|
|
|
|
"Your account is pending approval from your administrator and hence blocked."
|
2018-05-08 09:07:55 -04:00
|
|
|
when :terms_not_accepted
|
2018-05-24 03:46:30 -04:00
|
|
|
"You (#{@user.to_reference}) must accept the Terms of Service in order to perform this action. "\
|
2021-11-23 10:11:19 -05:00
|
|
|
"To accept these terms, please access GitLab from a web browser at #{Gitlab.config.gitlab.url}."
|
2019-10-09 20:06:44 -04:00
|
|
|
when :deactivated
|
|
|
|
"Your account has been deactivated by your administrator. "\
|
|
|
|
"Please log back in from a web browser to reactivate your account at #{Gitlab.config.gitlab.url}"
|
2020-07-27 17:09:16 -04:00
|
|
|
when :unconfirmed
|
|
|
|
"Your primary email address is not confirmed. "\
|
|
|
|
"Please check your inbox for the confirmation instructions. "\
|
|
|
|
"In case the link is expired, you can request a new confirmation email at #{Rails.application.routes.url_helpers.new_user_confirmation_url}"
|
2021-06-16 14:10:35 -04:00
|
|
|
when :blocked
|
|
|
|
"Your account has been blocked."
|
2021-06-01 17:10:06 -04:00
|
|
|
when :password_expired
|
|
|
|
"Your password expired. "\
|
|
|
|
"Please access GitLab from a web browser to update your password."
|
2018-05-08 09:07:55 -04:00
|
|
|
else
|
2018-05-24 03:46:30 -04:00
|
|
|
"Your account has been blocked."
|
2018-05-08 09:07:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def rejection_type
|
|
|
|
if @user.internal?
|
|
|
|
:internal
|
2020-10-06 08:08:38 -04:00
|
|
|
elsif @user.blocked_pending_approval?
|
|
|
|
:blocked_pending_approval
|
2018-05-08 09:07:55 -04:00
|
|
|
elsif @user.required_terms_not_accepted?
|
|
|
|
:terms_not_accepted
|
2019-10-09 20:06:44 -04:00
|
|
|
elsif @user.deactivated?
|
|
|
|
:deactivated
|
2020-07-27 17:09:16 -04:00
|
|
|
elsif !@user.confirmed?
|
|
|
|
:unconfirmed
|
2021-06-16 14:10:35 -04:00
|
|
|
elsif @user.blocked?
|
|
|
|
:blocked
|
2021-06-01 17:10:06 -04:00
|
|
|
elsif @user.password_expired?
|
|
|
|
:password_expired
|
2018-05-08 09:07:55 -04:00
|
|
|
else
|
|
|
|
:blocked
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|