Class: Blogo::Admin::SessionsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- Blogo::ApplicationController
- BaseController
- Blogo::Admin::SessionsController
- Defined in:
- app/controllers/blogo/admin/sessions_controller.rb
Overview
Responsible for authentication of blog users. Simply performs 2 operation: login and logout. User is logged in if it has set sessions.
Instance Method Summary collapse
-
#create ⇒ Object
POST /admin/sessions.
-
#destroy ⇒ Object
GET /admin/logout.
-
#new ⇒ Object
GET /admin/login.
Instance Method Details
#create ⇒ Object
POST /admin/sessions
16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/blogo/admin/sessions_controller.rb', line 16 def create user = Blogo::User.find_by_email(params[:email]) if user && user.authenticate(params[:password]) session[:blogo_user_id] = user.id redirect_to blogo_admin_url, notice: I18n.translate('blogo.admin.logged_in') else flash.now.alert = I18n.translate('blogo.admin.login_fail') render "new" end end |
#destroy ⇒ Object
GET /admin/logout
30 31 32 33 |
# File 'app/controllers/blogo/admin/sessions_controller.rb', line 30 def destroy session[:blogo_user_id] = nil redirect_to blogo_admin_url, notice: I18n.translate('blogo.admin.logged_out') end |
#new ⇒ Object
GET /admin/login
11 12 |
# File 'app/controllers/blogo/admin/sessions_controller.rb', line 11 def new end |