Sha256: 99ab964d068f05e6506dd91364b001fec5782f14a3081336efffd5b180329f9a
Contents?: true
Size: 590 Bytes
Versions: 18
Compression:
Stored size: 590 Bytes
Contents
module AuthManagment def sign_in(user) session[:user_id] = user.id end def sign_out session[:user_id] = nil end def signed_in? current_user end def authenticate_user! redirect_to new_session_path unless signed_in? end def authenticate_admin! if signed_in? redirect_to ::Tramway::User.root_path if !current_user.admin? && request.env['PATH_INFO'] != ::Tramway::User.root_path else redirect_to '/users/session/new' end end def current_user @_current_user ||= ::Tramway::User::User.find_by id: session[:user_id] end end
Version data entries
18 entries across 18 versions & 1 rubygems