summaryrefslogtreecommitdiff
path: root/lib/gitlab/auth/user_access_denied_reason.rb
blob: af310aa12fce986e091d0e732774e0af0a75134a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module Gitlab
  module Auth
    class UserAccessDeniedReason
      def initialize(user)
        @user = user
      end

      def rejection_message
        case rejection_type
        when :internal
          'This action cannot be performed by internal users'
        when :terms_not_accepted
          'You must accept the Terms of Service in order to perform this action. '\
          'Please access GitLab from a web browser to accept these terms.'
        else
          'Your account has been blocked.'
        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