Class: Smithy::UserSessionsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/smithy/user_sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/smithy/user_sessions_controller.rb', line 9

def create
  Smithy.log :debug, "[Auth] Entering UserSessionsController#create"
  user = User.find_by_email(filtered_params[:email])
  Smithy.log :debug, "[Auth] user found: #{user.inspect}"
  if user && user.authenticate(filtered_params[:password])
    Smithy.log :debug, "[Auth] User authenticated"
    session[:user_id] = user.id
    Smithy.log :debug, "[Auth] session[:user_id]: #{session[:user_id].inspect}"
    redirect_to pages_path, :notice => "Logged in!"
  else
    flash.now.alert = "Invalid email or password"
    render "new"
  end
end

#destroyObject



24
25
26
27
28
29
# File 'app/controllers/smithy/user_sessions_controller.rb', line 24

def destroy
  session[:user_id] = nil
  Smithy.log :debug, "[Auth] User signed out"
  Smithy.log :debug, "[Auth] session[:user_id]: #{session[:user_id].inspect}"
  redirect_to root_url, :notice => "Logged out!"
end

#newObject



5
6
7
# File 'app/controllers/smithy/user_sessions_controller.rb', line 5

def new
  Smithy.log :debug, "[Auth] Entering UserSessionsController#new"
end