Class: SessionsController

Inherits:
ApplicationController show all
Defined in:
lib/generators/iceauth/templates/app/controllers/sessions_controller.rb

Instance Method Summary collapse

Methods included from SessionsHelper

#authenticate, #current_user, #signed_in?, #signin, #signout

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/generators/iceauth/templates/app/controllers/sessions_controller.rb', line 7

def create    
  user = (User.where(:username => params[:session][:login]) | User.where(:email => params[:session][:login])).first
  if user && user.authenticate(params[:session][:password])
    (user, params[:session][:remember_me])
    redirect_to root_url, :flash => {:success => "Logged in!"}
  else
    flash.now[:error] = "Invalid login/password combination."
    @title = "Sign in"
    render 'new'
  end
end

#destroyObject



19
20
21
22
# File 'lib/generators/iceauth/templates/app/controllers/sessions_controller.rb', line 19

def destroy
  signout
  redirect_to root_url, :notice => "Logged out!"
end

#newObject



3
4
5
# File 'lib/generators/iceauth/templates/app/controllers/sessions_controller.rb', line 3

def new
  @title = "Sign In"
end