Module: RailsJwtAuth::AuthenticableHelper
- Defined in:
- app/controllers/concerns/rails_jwt_auth/authenticable_helper.rb
Instance Method Summary collapse
- #authenticate ⇒ Object
- #authenticate! ⇒ Object
- #current_user ⇒ Object
- #signed_in? ⇒ Boolean
- #unauthorize! ⇒ Object
Instance Method Details
#authenticate ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/concerns/rails_jwt_auth/authenticable_helper.rb', line 27 def authenticate begin payload = RailsJwtAuth::JwtManager.decode_from_request(request).first @current_user = RailsJwtAuth.model.from_token_payload(payload) rescue JWT::ExpiredSignature, JWT::VerificationError, JWT::DecodeError @current_user = nil end if @current_user&.respond_to? :update_tracked_fields! @current_user.update_tracked_fields!(request) end end |
#authenticate! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/concerns/rails_jwt_auth/authenticable_helper.rb', line 13 def authenticate! begin payload = RailsJwtAuth::JwtManager.decode_from_request(request).first rescue JWT::ExpiredSignature, JWT::VerificationError, JWT::DecodeError end if !@current_user = RailsJwtAuth.model.from_token_payload(payload) elsif @current_user.respond_to? :update_tracked_fields! @current_user.update_tracked_fields!(request) end end |
#current_user ⇒ Object
5 6 7 |
# File 'app/controllers/concerns/rails_jwt_auth/authenticable_helper.rb', line 5 def current_user @current_user end |
#signed_in? ⇒ Boolean
9 10 11 |
# File 'app/controllers/concerns/rails_jwt_auth/authenticable_helper.rb', line 9 def signed_in? !current_user.nil? end |
#unauthorize! ⇒ Object
40 41 42 |
# File 'app/controllers/concerns/rails_jwt_auth/authenticable_helper.rb', line 40 def raise NotAuthorized end |