Class: AsUser::SessionsController

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

Instance Method Summary collapse

Methods included from SessionsHelper

#current_user, #current_user=, #current_user?, #redirect_back_or, #sign_in, #sign_out, #signed_in?, #store_location

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/as_user/sessions_controller.rb', line 11

def create
  user = User.find_by_name(params[:session][:name]) || User.find_by_email(params[:session][:email].to_s.downcase)
  if user && user.authenticate(params[:session][:password])
     user
    redirect_back_or main_app.root_path
  else
    flash.now[:error] = "Invalid name(or email)/password combination"
    render 'new'
  end
end

#destroyObject



22
23
24
25
26
27
# File 'app/controllers/as_user/sessions_controller.rb', line 22

def destroy
  sign_out
  flash[:notice] = "signed out."
  #redirect_back_or main_app.root_path
  redirect_to main_app.root_path
end

#newObject



5
6
7
8
9
# File 'app/controllers/as_user/sessions_controller.rb', line 5

def new
  if signed_in? then
    redirect_to current_user
  end
end