Module: Credible::Controllers::SessionsController

Extended by:
ActiveSupport::Concern
Included in:
SessionsController
Defined in:
lib/credible/controllers/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

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

#destroyObject

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

#failObject



64
65
66
# File 'lib/credible/controllers/sessions_controller.rb', line 64

def fail
  render json: {}, status: :unauthorized
end

#indexObject

GET /sessions GET /sessions.json



16
17
# File 'lib/credible/controllers/sessions_controller.rb', line 16

def index
end

#newObject

GET /sessions/new



25
26
27
# File 'lib/credible/controllers/sessions_controller.rb', line 25

def new
  @session = ::Session.new
end

#refreshObject

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

#showObject

GET /sessions/1 GET /sessions/1.json



21
22
# File 'lib/credible/controllers/sessions_controller.rb', line 21

def show
end