Sha256: 365eae69636f112391e16ca9961691634a067c99dff61032d2ad740f0eb1e53c
Contents?: true
Size: 895 Bytes
Versions: 2
Compression:
Stored size: 895 Bytes
Contents
module Outpost module Controller module Authentication extend ActiveSupport::Concern included do before_filter :require_login helper_method :current_user end # Public: The currently logged-in user. # # Returns Outpost.user_class instance. def current_user begin @current_user ||= Outpost.user_class .where(can_login: true).find(session[:user_id]) rescue ActiveRecord::RecordNotFound session[:user_id] = nil @current_user = nil end end # Private: Callback to require login. # # Returns nothing. def require_login if !current_user session[:return_to] = request.fullpath redirect_to outpost_login_path and return false end end end # Authentication end # Controller end # Outpost
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
outpost-cms-0.0.5 | lib/outpost/controller/authentication.rb |
outpost-cms-0.0.4 | lib/outpost/controller/authentication.rb |