Class: JwtAuthEngine::SessionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- JwtAuthEngine::SessionsController
- Includes:
- Serializable, Tokenizable
- Defined in:
- app/controllers/jwt_auth_engine/sessions_controller.rb
Overview
Login and logout endpoints for session token lifecycle.
Instance Method Summary collapse
-
#login ⇒ Object
── POST /login ──────────────────────────────────────────────────────────.
-
#logout ⇒ Object
── DELETE /logout ───────────────────────────────────────────────────────── Stateless logout: the client should discard tokens.
Methods included from ResponseRenderable
#render_internal_server_error, #render_success, #render_unauthorized, #render_validation_error
Instance Method Details
#login ⇒ Object
── POST /login ──────────────────────────────────────────────────────────
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/jwt_auth_engine/sessions_controller.rb', line 12 def login result = LoginService.new(login_params: login_params).call return (result[:error]) unless result[:success] auth_model_instance = result[JwtAuthEngine.auth_model_name] render_success( message: 'Login successful.', JwtAuthEngine.auth_model_name => serialize_auth_model_instance(auth_model_instance), **issue_tokens(auth_model_instance) ) end |
#logout ⇒ Object
── DELETE /logout ───────────────────────────────────────────────────────── Stateless logout: the client should discard tokens.
28 29 30 |
# File 'app/controllers/jwt_auth_engine/sessions_controller.rb', line 28 def logout render_success(status: :no_content) end |