Class: CargoWiki::SessionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- CargoWiki::SessionsController
- Defined in:
- app/controllers/cargo_wiki/sessions_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/cargo_wiki/sessions_controller.rb', line 9 def create user = User.find_by_username(params[:username]) if user && user.authenticate(params[:password]) params[:remember_me] ? .permanent[:auth_token] = user.auth_token : [:auth_token] = user.auth_token redirect_to root_url, :notice => "Logged in!" else flash.now.alert = "Invalid username or password" render "new" end end |
#destroy ⇒ Object
20 21 22 23 |
# File 'app/controllers/cargo_wiki/sessions_controller.rb', line 20 def destroy .delete(:auth_token) redirect_to root_url, :notice => "Logged out!" end |
#new ⇒ Object
3 4 5 6 7 |
# File 'app/controllers/cargo_wiki/sessions_controller.rb', line 3 def new if signed_in? redirect_to root_url, :alert => "You're already logged in" end end |