Sha256: 604fb197d96b659c9b35cb84b8f9bfd32ab924de3be16630e5485f5e39258428
Contents?: true
Size: 589 Bytes
Versions: 5
Compression:
Stored size: 589 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::Auth.root_path if !current_user.admin? && request.env['PATH_INFO'] != ::Tramway::Auth.root_path else redirect_to '/auth/session/new' end end def current_user @_current_user ||= ::Tramway::User::User.find_by id: session[:user_id] end end
Version data entries
5 entries across 5 versions & 1 rubygems