Module: Credible::Controllers::SessionsController
- Extended by:
- ActiveSupport::Concern
- Included in:
- SessionsController
- Defined in:
- lib/credible/controllers/sessions_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /sessions POST /sessions.json.
-
#destroy ⇒ Object
DELETE /sessions/1 DELETE /sessions/1.json DELETE /sessions/current DELETE /sessions/current.json.
- #fail ⇒ Object
-
#index ⇒ Object
GET /sessions GET /sessions.json.
-
#new ⇒ Object
GET /sessions/new.
-
#refresh ⇒ Object
POST /refresh POST /refresh.json.
-
#show ⇒ Object
GET /sessions/1 GET /sessions/1.json.
Instance Method Details
#create ⇒ Object
POST /sessions POST /sessions.json
31 32 33 34 35 36 37 38 39 |
# File 'lib/credible/controllers/sessions_controller.rb', line 31 def create @session = ::Session.authenticate(session_params) if @session.save render :show, status: :created, location: @session else render json: @session.errors, status: :unprocessable_entity end end |
#destroy ⇒ Object
DELETE /sessions/1 DELETE /sessions/1.json DELETE /sessions/current DELETE /sessions/current.json
58 59 60 61 62 |
# File 'lib/credible/controllers/sessions_controller.rb', line 58 def destroy warden.logout @session.destroy head :no_content end |
#fail ⇒ Object
64 65 66 |
# File 'lib/credible/controllers/sessions_controller.rb', line 64 def fail render json: {}, status: :unauthorized end |
#index ⇒ Object
GET /sessions GET /sessions.json
16 17 |
# File 'lib/credible/controllers/sessions_controller.rb', line 16 def index end |
#new ⇒ Object
GET /sessions/new
25 26 27 |
# File 'lib/credible/controllers/sessions_controller.rb', line 25 def new @session = ::Session.new end |
#refresh ⇒ Object
POST /refresh POST /refresh.json
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/credible/controllers/sessions_controller.rb', line 43 def refresh @session = ::Session.new(user: current_user) if @session.save current_session.destroy render :show, status: :created, location: @session else render json: @session.errors, status: :unprocessable_entity end end |
#show ⇒ Object
GET /sessions/1 GET /sessions/1.json
21 22 |
# File 'lib/credible/controllers/sessions_controller.rb', line 21 def show end |