Module: Wallaby::SecureHelper
- Defined in:
- lib/helpers/wallaby/secure_helper.rb
Overview
Secure helper
Instance Method Summary collapse
-
#logout_method(user = current_user) ⇒ String, Symbol
Logout method for given user.
-
#logout_path(user = current_user, app = main_app) ⇒ String
Logout path for given user.
-
#user_portrait(user = current_user) ⇒ String
Image portrait for given user.
Instance Method Details
#logout_method(user = current_user) ⇒ String, Symbol
Logout method for given user
35 36 37 38 39 40 41 42 |
# File 'lib/helpers/wallaby/secure_helper.rb', line 35 def logout_method(user = current_user) http_method = Wallaby.configuration.security.logout_method http_method || if defined? ::Devise scope = ::Devise::Mapping.find_scope! user mapping = ::Devise.mappings[scope] mapping.sign_out_via end end |
#logout_path(user = current_user, app = main_app) ⇒ String
Logout path for given user
24 25 26 27 28 29 30 31 |
# File 'lib/helpers/wallaby/secure_helper.rb', line 24 def logout_path(user = current_user, app = main_app) path = Wallaby.configuration.security.logout_path path ||= if defined? ::Devise scope = ::Devise::Mapping.find_scope! user "destroy_#{scope}_session_path" end app.public_send path if path && app.respond_to?(path) end |
#user_portrait(user = current_user) ⇒ String
Image portrait for given user
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/helpers/wallaby/secure_helper.rb', line 7 def user_portrait(user = current_user) email_method = Wallaby.configuration.security.email_method || :email email = user.respond_to?(email_method) && user.public_send(email_method) if email.present? https = "http#{request.ssl? ? 's' : EMPTY_STRING}" email_md5 = ::Digest::MD5.hexdigest email.downcase image_source = "#{https}://www.gravatar.com/avatar/#{email_md5}" image_tag image_source, class: 'hidden-xs user-portrait' else content_tag :i, nil, class: 'fa fa-user user-portrait' end end |