Sha256: 01c5935a85ab672aad842aa5a796936a20ac69691041daaeabfa74006a616c2c
Contents?: true
Size: 1.01 KB
Versions: 5
Compression:
Stored size: 1.01 KB
Contents
class SessionsController < ApplicationController def new set_target_page redirect_to root_path if current_user end def create set_target_page user = User.find_by_email(params[:email]) if user && user.authenticate(params[:password]) if params[:remember_me] cookies.permanent[:auth_token] = user.auth_token else cookies[:auth_token] = user.auth_token end redirect_to (session[:target_page] || safe_root_url), notice: t('authentication.login_confirmation') destroy_target_page else flash.now.alert = t('authentication.warning.email_or_password_invalid') render "new" end end def destroy cookies.delete(:auth_token) destroy_target_page redirect_to safe_root_url, notice: t('authentication.logout_confirmation') end private def set_target_page session[:target_page] = request.referer unless session[:target_page] # && !request.referer.nil? end def destroy_target_page session[:target_page] = nil end end
Version data entries
5 entries across 5 versions & 1 rubygems