Class: SessionsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/authpro/templates/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/generators/authpro/templates/sessions_controller.rb', line 6

def create
  @user = User.authenticate(params[:email], params[:password])
  if @user
    if params[:remember_me]
      cookies.permanent[:auth_token] = @user.auth_token
    else
      cookies[:auth_token] = @user.auth_token  
    end

    redirect_to root_url, notice: "Logged in!"
  else
    flash.now.alert = "Invalid email or password"
    render "new"
  end
end

#destroyObject



22
23
24
25
# File 'lib/generators/authpro/templates/sessions_controller.rb', line 22

def destroy
  cookies.delete(:auth_token)
  redirect_to root_url, notice: "Logged out!"
end

#newObject



3
4
# File 'lib/generators/authpro/templates/sessions_controller.rb', line 3

def new
end