2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
module Gitlab
|
|
|
|
module Auth
|
|
|
|
class UserAccessDeniedReason
|
|
|
|
def initialize(user)
|
|
|
|
@user = user
|
|
|
|
end
|
|
|
|
|
|
|
|
def rejection_message
|
|
|
|
case rejection_type
|
|
|
|
when :internal
|
2018-11-08 19:23:39 +05:30
|
|
|
"This action cannot be performed by internal users"
|
2018-10-15 14:42:47 +05:30
|
|
|
when :terms_not_accepted
|
2018-11-08 19:23:39 +05:30
|
|
|
"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."
|
2019-12-21 20:55:43 +05:30
|
|
|
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}"
|
2018-10-15 14:42:47 +05:30
|
|
|
else
|
2018-11-08 19:23:39 +05:30
|
|
|
"Your account has been blocked."
|
2018-10-15 14:42:47 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def rejection_type
|
|
|
|
if @user.internal?
|
|
|
|
:internal
|
|
|
|
elsif @user.required_terms_not_accepted?
|
|
|
|
:terms_not_accepted
|
2019-12-21 20:55:43 +05:30
|
|
|
elsif @user.deactivated?
|
|
|
|
:deactivated
|
2018-10-15 14:42:47 +05:30
|
|
|
else
|
|
|
|
:blocked
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|