Class: Outpost::SessionsController
Constant Summary
Controller::CustomErrors::NOT_FOUND_ERROR_CLASSES
Instance Method Summary
collapse
#current_user, #require_login
#authorize, #authorize_resource, #handle_unauthorized
#breadcrumb
Instance Method Details
#create ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/outpost/sessions_controller.rb', line 12
def create
if user = Outpost.user_class.authenticate(
params[@authentication_attribute], params[:password])
session[:user_id] = user.id
user.update_column(:last_login, Time.zone.now)
redirect_to session[:return_to] || outpost.root_path,
notice: "Logged in."
session[:return_to] = nil
else
flash.now[:alert] = "Invalid login information."
render :new
end
end
|
#destroy ⇒ Object
29
30
31
32
33
|
# File 'app/controllers/outpost/sessions_controller.rb', line 29
def destroy
@current_user = nil
session[:user_id] = nil
redirect_to outpost.login_path, notice: "Logged Out."
end
|
#new ⇒ Object
8
9
10
|
# File 'app/controllers/outpost/sessions_controller.rb', line 8
def new
redirect_to outpost.root_path if current_user
end
|