Class: RailsJwtAuth::SessionsController

Inherits:
ApplicationController
  • Object
show all
Includes:
AuthenticableHelper, ParamsHelper, RenderHelper
Defined in:
app/controllers/rails_jwt_auth/sessions_controller.rb

Instance Method Summary collapse

Methods included from RenderHelper

#render_204, #render_404, #render_410, #render_422, #render_profile, #render_registration, #render_session

Methods included from AuthenticableHelper

#authenticate, #authenticate!, #current_user, #get_jwt_from_request, #jwt_payload, #signed_in?, #track_request, #unauthorize!

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
# File 'app/controllers/rails_jwt_auth/sessions_controller.rb', line 7

def create
  se = Session.new(session_create_params)

  if se.generate!(request)
    render_session se.jwt, se.user
  else
    render_422 se.errors.details
  end
end

#destroyObject



17
18
19
20
21
22
23
# File 'app/controllers/rails_jwt_auth/sessions_controller.rb', line 17

def destroy
  return render_404 unless RailsJwtAuth.simultaneous_sessions.positive?

  authenticate!
  current_user.destroy_auth_token @jwt_payload['auth_token']
  render_204
end