debian-mirror-gitlab/lib/gitlab/auth/user_access_denied_reason.rb

47 lines
1.4 KiB
Ruby
Raw Normal View History

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}"
2020-08-09 18:53:13 +05:30
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}"
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
2020-08-09 18:53:13 +05:30
elsif !@user.confirmed?
:unconfirmed
2018-10-15 14:42:47 +05:30
else
:blocked
end
end
end
end
end