Module: EasyAuthHelper
- Defined in:
- app/helpers/easy_auth_helper.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#account_not_signed_in? ⇒ Boolean
(also: #user_not_signed_in?)
Should be used to test if user is not authenticated.
-
#account_signed_in? ⇒ Boolean
(also: #user_signed_in?)
Should be used to test if user is authenticated.
-
#current_account ⇒ Account
(also: #current_user)
Access the current account the users is authenticated with.
Class Method Details
.included(base) ⇒ Object
2 3 4 5 6 |
# File 'app/helpers/easy_auth_helper.rb', line 2 def self.included(base) base.class_eval do helper_method :current_account, :current_user, :account_signed_in?, :user_signed_in?, :account_not_signed_in?, :user_not_signed_in? end end |
Instance Method Details
#account_not_signed_in? ⇒ Boolean Also known as: user_not_signed_in?
Should be used to test if user is not authenticated
42 43 44 |
# File 'app/helpers/easy_auth_helper.rb', line 42 def account_not_signed_in? !account_signed_in? end |
#account_signed_in? ⇒ Boolean Also known as: user_signed_in?
Should be used to test if user is authenticated
36 37 38 |
# File 'app/helpers/easy_auth_helper.rb', line 36 def account_signed_in? current_account end |
#current_account ⇒ Account Also known as: current_user
Access the current account the users is authenticated with
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/easy_auth_helper.rb', line 11 def current_account if session[:session_token] && session[:account_class] begin @current_account ||= session[:account_class].constantize.find_by_session_token(session[:session_token]) rescue @current_account = nil session.delete(:session_token) end elsif [:remember_token] begin @current_account ||= EasyAuth.identity_model.find_by_remember_token([:remember_token]).account rescue @current_acount = nil .delete(:remember_token) end else session.delete(:session_token) .delete(:remember_token) end @current_account end |