Class: Compartment::Admin::SessionsController
- Inherits:
-
Compartment::ApplicationController
- Object
- ActionController::Base
- Compartment::ApplicationController
- Compartment::Admin::SessionsController
- Defined in:
- app/controllers/compartment/admin/sessions_controller.rb
Instance Attribute Summary
Attributes inherited from Compartment::ApplicationController
Instance Method Summary collapse
Methods inherited from Compartment::ApplicationController
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/compartment/admin/sessions_controller.rb', line 12 def create if params[:email].empty? or params[:password].empty? flash.now.alert = "Invalid email or password" return render "new" end user = current_site.users.find_by_email(params[:email]) if user && user.authenticate(params[:password]) session[:user_id] = user.id redirect_to admin_dashboard_url, :notice => "Logged in!" else flash.now.alert = "Invalid email or password" render "new" end end |
#destroy ⇒ Object
28 29 30 31 |
# File 'app/controllers/compartment/admin/sessions_controller.rb', line 28 def destroy session[:user_id] = nil redirect_to root_url, :notice => "Logged out!" end |
#new ⇒ Object
9 10 |
# File 'app/controllers/compartment/admin/sessions_controller.rb', line 9 def new end |