Class: SessionsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- SessionsController
- Defined in:
- app/controllers/sessions_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/sessions_controller.rb', line 7 def create user = User.find_by_email(params[:email]) set_target_page if user && user.authenticate(params[:password]) if params[:remember_me] .permanent[:auth_token] = user.auth_token else [:auth_token] = user.auth_token end redirect_to (session[:target_page] || safe_root_url), notice: t('authentication.login_confirmation') session[:target_page] = nil else flash.now.alert = t('authentication.warning.email_or_password_invalid') render "new" end end |
#destroy ⇒ Object
24 25 26 27 |
# File 'app/controllers/sessions_controller.rb', line 24 def destroy .delete(:auth_token) redirect_to safe_root_url, notice: t('authentication.logout_confirmation') end |
#new ⇒ Object
3 4 5 |
# File 'app/controllers/sessions_controller.rb', line 3 def new redirect_to root_path if current_user end |