Class: Plotline::SessionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/plotline/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/plotline/sessions_controller.rb', line 12

def create
  user = User.find_by_email(params[:email])
  if user && user.authenticate(params[:password])
    cookies.permanent[:auth_token] = user.auth_token

    flash[:notice] = "Hello!"
    redirect_to root_url
  else
    flash.now.alert = "Invalid email and/or password"
    render "new"
  end
end

#destroyObject



25
26
27
28
# File 'app/controllers/plotline/sessions_controller.rb', line 25

def destroy
  cookies.delete(:auth_token)
  redirect_to root_url
end

#newObject



9
10
# File 'app/controllers/plotline/sessions_controller.rb', line 9

def new
end