Sha256: bd3886679c17e39e44cb487fe354355d93055f340901c3ca07384a61bf8d6f94
Contents?: true
Size: 880 Bytes
Versions: 2
Compression:
Stored size: 880 Bytes
Contents
module AsUser module SessionsHelper def sign_in(user) session[:user_id] = user.id self.current_user = user end def signed_in? #session[:original_url] = request.url !current_user.nil? end def sign_out #cookies.delete(:remember_token) session[:user_id] = nil self.current_user = nil end def current_user=(user) @current_user = user end def current_user #@current_user ||= User.find_by_remember_token(cookies[:remember_token]) @current_user ||= User.find_by_id(session[:user_id]) if session[:user_id] end def current_user?(user) user == current_user end def redirect_back_or(default) redirect_to(session[:return_to] || default) session.delete(:return_to) end def store_location session[:return_to] = request.url end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
as_user-0.0.4 | app/helpers/as_user/sessions_helper.rb |
as_user-0.0.3 | app/helpers/as_user/sessions_helper.rb |