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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

62 lines
2 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"
2021-01-03 14:25:43 +05:30
when :blocked_pending_approval
"Your account is pending approval from your administrator and hence blocked."
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. "\
2022-01-26 12:08:38 +05:30
"To accept these terms, please access GitLab from a web browser at #{Gitlab.config.gitlab.url}."
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}"
2021-07-02 01:05:55 +05:30
when :blocked
"Your account has been blocked."
2021-06-02 17:11:27 +05:30
when :password_expired
"Your password expired. "\
"Please access GitLab from a web browser to update your password."
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
2021-01-03 14:25:43 +05:30
elsif @user.blocked_pending_approval?
:blocked_pending_approval
2018-10-15 14:42:47 +05:30
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
2021-07-02 01:05:55 +05:30
elsif @user.blocked?
:blocked
2021-06-02 17:11:27 +05:30
elsif @user.password_expired?
:password_expired
2018-10-15 14:42:47 +05:30
else
:blocked
end
end
end
end
end
2022-10-11 01:57:18 +05:30
Gitlab::Auth::UserAccessDeniedReason.prepend_mod