Class: Concen::SessionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Concen::SessionsController
- Defined in:
- app/controllers/concen/sessions_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/concen/sessions_controller.rb', line 11 def create user = User.where(:username => /#{params[:username]}/i).first if user && user.authenticate(params[:password]) .permanent[:auth_token] = user.auth_token redirect_to concen_root_path, :notice => "You have successfully signed in!" else flash.now.alert = "Invalid email or password" render "new" end end |
#destroy ⇒ Object
23 24 25 26 |
# File 'app/controllers/concen/sessions_controller.rb', line 23 def destroy .delete(:auth_token) redirect_to root_path, :notice => "You have successfully signed out!" end |
#new ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/controllers/concen/sessions_controller.rb', line 3 def new if User.all.any? render else redirect_to new_concen_user_path end end |