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"
|
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. "\
|
|
|
|
"Please access GitLab from a web browser to accept these terms."
|
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
|
|
|
|
elsif @user.required_terms_not_accepted?
|
|
|
|
:terms_not_accepted
|
|
|
|
else
|
|
|
|
:blocked
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|