Module: JWT::Auth::Authentication
- Defined in:
- lib/jwt/auth/authentication.rb
Overview
Controller methods
Instance Method Summary collapse
-
#authenticate_user ⇒ Object
Authenticate a request.
-
#current_user ⇒ Object
Current user helper.
-
#renew_token ⇒ Object
Add JWT header to response.
Instance Method Details
#authenticate_user ⇒ Object
Authenticate a request
21 22 23 |
# File 'lib/jwt/auth/authentication.rb', line 21 def authenticate_user raise JWT::Auth::UnauthorizedError unless jwt && jwt.valid? end |
#current_user ⇒ Object
Current user helper
14 15 16 |
# File 'lib/jwt/auth/authentication.rb', line 14 def current_user jwt && jwt.subject end |
#renew_token ⇒ Object
Add JWT header to response
28 29 30 31 32 |
# File 'lib/jwt/auth/authentication.rb', line 28 def renew_token return unless jwt && jwt.valid? jwt.renew! response.headers['Authorization'] = "Bearer #{jwt.to_jwt}" end |