Module: Opro::Controllers::Concerns::ErrorMessages

Extended by:
ActiveSupport::Concern
Included in:
ApplicationControllerHelper
Defined in:
lib/opro/controllers/concerns/error_messages.rb

Instance Method Summary collapse

Instance Method Details

#generate_oauth_error_message!Object



4
5
6
7
8
9
10
11
12
# File 'lib/opro/controllers/concerns/error_messages.rb', line 4

def generate_oauth_error_message!
  msg = ""
  msg << ' - No OAuth token provided!'    if oauth_access_token.blank?
  msg << ' - `Allow OAuth` is set to false!'   if allow_oauth? == false
  msg << ' - OAuth user not found!'       if oauth_user.blank?
  msg << ' - OAuth client has been rate limited' if oauth_client_over_rate_limit?
  msg = generate_oauth_permissions_error_message!(msg)
  msg
end

#generate_oauth_permissions_error_message!(msg = '') ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/opro/controllers/concerns/error_messages.rb', line 14

def generate_oauth_permissions_error_message!(msg = '')
  if !oauth_client_has_permissions?
    msg << ' - OAuth client not permitted'
    oauth_required_permissions.each do |permission|
      msg << "- #{permission} permission required" unless oauth_client_has_permission?(permission)
    end
  end
  msg
end