Class: AsUser::SessionsController
Instance Method Summary
collapse
#current_user, #current_user=, #current_user?, #redirect_back_or, #sign_in, #sign_out, #signed_in?, #store_location
Instance Method Details
#create ⇒ Object
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])
sign_in user
redirect_back_or main_app.root_path
else
flash.now[:error] = "Invalid name(or email)/password combination"
render 'new'
end
end
|
#destroy ⇒ Object
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_to main_app.root_path
end
|
#new ⇒ Object
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
|