Class: Authenticate::SessionsController

Inherits:
AuthenticateController show all
Defined in:
app/controllers/authenticate/sessions_controller.rb

Overview

Allow authenticate users to log in and log out.

Instance Method Summary collapse

Instance Method Details

#createObject

Log the user in, with the provided name and password.



19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/authenticate/sessions_controller.rb', line 19

def create
  @user = authenticate(params)
  (@user) do |status|
    if status.success?
      redirect_back_or url_after_create
    else
      flash.now.notice = status.message
      render template: 'sessions/new', status: :unauthorized
    end
  end
end

#destroyObject

Log the user out



34
35
36
37
# File 'app/controllers/authenticate/sessions_controller.rb', line 34

def destroy
  logout
  redirect_to url_after_destroy
end

#newObject

Render the login screen.



12
13
14
# File 'app/controllers/authenticate/sessions_controller.rb', line 12

def new
  render template: 'sessions/new'
end