Module: EasyAuthHelper

Defined in:
app/helpers/easy_auth_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

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

Returns:

  • (Boolean)


42
43
44
# File 'app/helpers/easy_auth_helper.rb', line 42

def 
  !
end

#account_signed_in?Boolean Also known as: user_signed_in?

Should be used to test if user is authenticated

Returns:

  • (Boolean)


36
37
38
# File 'app/helpers/easy_auth_helper.rb', line 36

def 
  
end

#current_accountAccount Also known as: current_user

Access the current account the users is authenticated with

Returns:

  • (Account)

    instance



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 
  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 cookies[:remember_token]
    begin
      @current_account ||= EasyAuth.identity_model.find_by_remember_token(cookies[:remember_token]).
    rescue
      @current_acount = nil
      cookies.delete(:remember_token)
    end
  else
    session.delete(:session_token)
    cookies.delete(:remember_token)
  end

  @current_account
end