Sha256: f0b8d6db918ab37f69194a311492350f7b413872f4e4b3b062a7a3bb09c69775
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
class Clearance::SessionsController < ApplicationController unloadable protect_from_forgery :except => :create filter_parameter_logging :password def new render :template => 'sessions/new' end def create @user = ::User.authenticate(params[:session][:email], params[:session][:password]) if @user.nil? flash.now[:notice] = t(:unauthorized, :scope => [:clearance, :controllers, :sessions], :default => "Bad email or password.") render :template => 'sessions/new', :status => :unauthorized else if @user.email_confirmed? remember(@user) if remember? sign_user_in(@user) flash[:notice] = t(:signed_in, :scope => [:clearance, :controllers, :sessions], :default => "Signed in successfully.") redirect_back_or url_after_create else ::ClearanceMailer.deliver_confirmation(@user) deny_access(t(:unconfirmed_email, :scope => [:clearance, :controllers, :sessions], :default => "User has not confirmed email. Confirmation email will be resent.")) end end end def destroy forget(current_user) reset_session flash[:notice] = t(:sign_out, :scope => [:clearance, :controllers, :sessions], :default => "You have been signed out.") redirect_to url_after_destroy end private def remember? params[:session] && params[:session][:remember_me] == "1" end def remember(user) user.remember_me! cookies[:remember_token] = { :value => user.token, :expires => user.token_expires_at } end def forget(user) user.forget_me! if user cookies.delete :remember_token end def url_after_create root_url end def url_after_destroy new_session_url end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vita-clearance-0.6.3.1 | app/controllers/clearance/sessions_controller.rb |