Module: IdentityToolbox::Authorizable
- Defined in:
- lib/identity_toolbox/authorizable.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/identity_toolbox/authorizable.rb', line 5 def self.included(klass) klass.class_eval do include Pundit rescue_from Pundit::NotAuthorizedError, with: :render_forbidden end end |
Instance Method Details
#current_user ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/identity_toolbox/authorizable.rb', line 12 def current_user header = request.headers['user-identifier'] return unless header user_identifier = JSON.parse(Base64.decode64(header), symbolize_names: true) UserEntity.new(user_identifier) end |
#render_forbidden(_exception) ⇒ Object
22 23 24 |
# File 'lib/identity_toolbox/authorizable.rb', line 22 def render_forbidden(_exception) render(errors) end |