Module: EasyJwtAuth::RailsHelper

Defined in:
lib/easy_jwt_auth/rails_helper.rb

Instance Method Summary collapse

Instance Method Details

#jwt_authenticate!Object



12
13
14
# File 'lib/easy_jwt_auth/rails_helper.rb', line 12

def jwt_authenticate!
  head(403) if jwt_current_user.nil?
end

#jwt_current_userObject



3
4
5
6
7
8
9
10
# File 'lib/easy_jwt_auth/rails_helper.rb', line 3

def jwt_current_user
  return @_jwt_current_user if defined?(@_jwt_current_user)

  auth_header = request.headers['Authorization']
  @_jwt_current_user = EasyJwtAuth::UserFinder.new.user_from_header(auth_header)
rescue StandardError => e
  nil
end