Module: EVSS::Authorizeable

Extended by:
ActiveSupport::Concern
Defined in:
app/controllers/concerns/evss/authorizeable.rb

Instance Method Summary collapse

Instance Method Details

#authorize_evss!Object



7
8
9
10
11
# File 'app/controllers/concerns/evss/authorizeable.rb', line 7

def authorize_evss!
  unless EVSSPolicy.new(@current_user, :evss).access?
    raise Common::Exceptions::Forbidden.new(detail: error_detail, source: 'EVSS')
  end
end

#error_detailObject (private)



15
16
17
# File 'app/controllers/concerns/evss/authorizeable.rb', line 15

def error_detail
  "User does not have access to the requested resource due to missing values: #{missing_values}"
end

#missing_valuesString (private)

Returns a comma-separated string of the user’s blank attributes. ‘participant_id` is AKA `corp_id`.

Returns:

  • (String)

    Comma-separated string of the attribute names



23
24
25
26
27
28
29
30
31
# File 'app/controllers/concerns/evss/authorizeable.rb', line 23

def missing_values
  missing = []

  missing << 'corp_id' if @current_user.participant_id.blank?
  missing << 'edipi' if @current_user.edipi.blank?
  missing << 'ssn' if @current_user.ssn.blank?

  missing.join(', ')
end