Class: JwtSecure::ApiJwtController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- JwtSecure::ApiJwtController
- Defined in:
- lib/jwt_secure/controllers.rb
Instance Method Summary collapse
Instance Method Details
#authenticate_jwtsecure ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/jwt_secure/controllers.rb', line 21 def authenticate_jwtsecure() begin payload = JsonWebToken.decode(get_auth_token, @jwtsecure_secret) if payload.present? @current_user = User.find(payload["user_id"]) else render json: {errors: ["Invalid Token, user not found!"]}, status: :unauthorized end rescue render json: {errors: ["token not found!"]}, status: :unauthorized end end |
#get_auth_token ⇒ Object
34 35 36 |
# File 'lib/jwt_secure/controllers.rb', line 34 def get_auth_token() @auth_token ||= .encrypted[@jwtsecure_cookiename] end |