Module: Auth::ApplicationHelper

Defined in:
app/helpers/auth/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#cancel_res_registration_path(opts = {}) ⇒ Object



89
90
91
# File 'app/helpers/auth/application_helper.rb', line 89

def cancel_res_registration_path(opts = {})
  send "cancel_#{res_name_small}_registration_path",opts
end

#current_resObject



21
22
23
24
# File 'app/helpers/auth/application_helper.rb', line 21

def current_res
  return if get_signed_in_scope.nil?
  send "current_#{get_signed_in_scope}"
end

#decide_proxy_resource(enforce_admin) ⇒ Object



60
61
62
63
64
65
66
# File 'app/helpers/auth/application_helper.rb', line 60

def decide_proxy_resource(enforce_admin)
  if enforce_admin == "yes"
    current_signed_in_resource
  else
    lookup_resource
  end
end

#destroy_res_session_path(opts = {}) ⇒ Object



85
86
87
# File 'app/helpers/auth/application_helper.rb', line 85

def destroy_res_session_path(opts = {})
  send "destroy_#{res_name_small}_session_path",opts
end

#edit_res_password_path(opts = {}) ⇒ Object



113
114
115
# File 'app/helpers/auth/application_helper.rb', line 113

def edit_res_password_path(opts = {})
  send "edit_#{res_name_small}_password_path",opts
end

#edit_res_registration_path(opts = {}) ⇒ Object



101
102
103
# File 'app/helpers/auth/application_helper.rb', line 101

def edit_res_registration_path(opts = {})
  send "edit_#{res_name_small}_registration_path",opts
end

#get_signed_in_scopeObject

returns the name in small case of the class of the currently signed in resource

Examples:

: will return ‘user’ or ‘admin’



9
10
11
12
13
14
15
16
17
18
19
# File 'app/helpers/auth/application_helper.rb', line 9

def get_signed_in_scope
  if signed_in?
    Devise.mappings.keys.each do |res|
      l = send "#{res.to_s}_signed_in?"
      if send "#{res.to_s}_signed_in?"
        return res.to_s
      end
    end
  end
  return 'user'
end

#new_res_confirmation_path(opts = {}) ⇒ Object



121
122
123
# File 'app/helpers/auth/application_helper.rb', line 121

def new_res_confirmation_path(opts = {})
  send "new_#{res_name_small}_confirmation_path",opts
end

#new_res_password_path(opts = {}) ⇒ Object



109
110
111
# File 'app/helpers/auth/application_helper.rb', line 109

def new_res_password_path(opts = {})
  send "new_#{res_name_small}_password_path",opts
end

#new_res_registration_path(opts = {}) ⇒ Object



97
98
99
# File 'app/helpers/auth/application_helper.rb', line 97

def new_res_registration_path(opts = {})
  send "new_#{res_name_small}_registration_path",opts
end

#new_res_session_path(opts = {}) ⇒ Object



77
78
79
# File 'app/helpers/auth/application_helper.rb', line 77

def new_res_session_path(opts = {})
  send "new_#{res_name_small}_session_path",opts
end

#new_res_unlock_path(opts = {}) ⇒ Object



129
130
131
# File 'app/helpers/auth/application_helper.rb', line 129

def new_res_unlock_path(opts = {})
  send "new_#{res_name_small}_unlock_path",opts
end

#res_confirmation_path(opts = {}) ⇒ Object



117
118
119
# File 'app/helpers/auth/application_helper.rb', line 117

def res_confirmation_path(opts = {})
  send "#{res_name_small}_confirmation_path",opts
end

#res_nameObject

@return : Upcase current resource name



33
34
35
36
# File 'app/helpers/auth/application_helper.rb', line 33

def res_name
  return unless current_res
  return current_res.class.name
end

#res_name_smallObject

@return : downcased current resource name



27
28
29
30
# File 'app/helpers/auth/application_helper.rb', line 27

def res_name_small
  return unless current_res
  return current_res.class.name.downcase
end

#res_password_path(opts = {}) ⇒ Object



105
106
107
# File 'app/helpers/auth/application_helper.rb', line 105

def res_password_path(opts = {})
  send "#{res_name_small}_password_path",opts
end

#res_registration_path(opts = {}) ⇒ Object



93
94
95
# File 'app/helpers/auth/application_helper.rb', line 93

def res_registration_path(opts = {})
  send "#{res_name_small}_registration_path",opts
end

#res_session_path(opts = {}) ⇒ Object



81
82
83
# File 'app/helpers/auth/application_helper.rb', line 81

def res_session_path(opts = {})
  send "#{res_name_small}_session_path",opts
end

#res_unlock_path(opts = {}) ⇒ Object



125
126
127
# File 'app/helpers/auth/application_helper.rb', line 125

def res_unlock_path(opts = {})
  send "#{res_name_small}_unlock_path",opts
end

#resource_in_navbar?(resource) ⇒ Boolean

SHOULD THE RESOURCE SIGN IN OPTIONS BE SHOWN IN THE NAV BAR?

Returns:

  • (Boolean)


39
40
41
42
# File 'app/helpers/auth/application_helper.rb', line 39

def resource_in_navbar?(resource)
  return false unless resource
  return (Auth.configuration.auth_resources[resource.class.name][:nav_bar] && Auth.configuration.)
end

#use_admin_as_proxy_user?Boolean

@return : true if the current signed in user is admin and there is no proxy user in the session.

Returns:

  • (Boolean)


55
56
57
58
# File 'app/helpers/auth/application_helper.rb', line 55

def use_admin_as_proxy_user?
  return false unless respond_to? :current_signed_in_user
  return current_signed_in_user.is_admin? && session[:proxy_user_id].nil?
end