Sha256: d2244b66c7f3fc8252d4ca2eebbc41c9c61c4410192cdcf4786283f894ec24bc
Contents?: true
Size: 886 Bytes
Versions: 1
Compression:
Stored size: 886 Bytes
Contents
module Iconly module SessionsHelper protected def logout_path Iconly.logout_path end def login_path Iconly.login_path end def current_user unless @current_user if (user_id = session[:user_id] || cookies.signed[:user_id]) @current_user = Iconly::User.find_by(id: user_id) end end @current_user end def sign_in(user_id) session[:user_id] = user_id cookies.signed[:user_id] = user_id end def sign_out session.delete(:user_id) cookies.signed[:user_id] = nil end def signed_in? current_user.present? end def require_sign_in return if signed_in? session[:redirect_after_login] = request.original_fullpath flash[:danger] = 'You need to be signed in to access this page.' redirect_to root_path end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
iconly-1.0.0 | app/helpers/iconly/sessions_helper.rb |