Sha256: 8ede93eba6344ef043fafa3fb312eeba0bdbb449f59b736101f93fd4140dd1c4
Contents?: true
Size: 1.88 KB
Versions: 2
Compression:
Stored size: 1.88 KB
Contents
module Clearance module App module Controllers module SessionsController def self.included(controller) controller.class_eval do protect_from_forgery :except => :create filter_parameter_logging :password def create @user = User.authenticate(params[:session][:email], params[:session][:password]) if @user.nil? flash.now[:notice] = "Bad email or password." render :action => :new else if @user.email_confirmed? remember(@user) if remember? sign_user_in(@user) flash[:notice] = "Signed in successfully" redirect_back_or url_after_create else deny_access("User has not confirmed email.") end end end def destroy forget(current_user) reset_session flash[:notice] = "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 end end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
nagybence-clearance-0.4.2 | lib/clearance/app/controllers/sessions_controller.rb |
thoughtbot-clearance-0.4.2 | lib/clearance/app/controllers/sessions_controller.rb |