Sha256: a9bc9a7749bc8bc59d8c799c3f05d3a34cf7ad737ab1643d460260c50d409413
Contents?: true
Size: 880 Bytes
Versions: 1
Compression:
Stored size: 880 Bytes
Contents
module CurrentUser module Controller module Helpers def self.included(base) helpers = %w(authenticate_user! current_user sign_in sign_out signed_in? user_signed_in?) base.hide_action *helpers base.helper_method *helpers end def authenticate_user! if current_user.nil? render_unauthorized end end def current_user user_id = session[::CurrentUser::USER_SESSION_KEY] ::User.find_by_id user_id end def sign_in(user) session[::CurrentUser::USER_SESSION_KEY] = user.id end def sign_out session[::CurrentUser::USER_SESSION_KEY] = nil end def signed_in?; end def user_signed_in?; end private def render_unauthorized render :text => 'Unauthorized', :status => :unauthorized end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
current_user-0.0.1 | lib/current_user/controller/helpers.rb |