Module: Wallaby::SecureHelper
- Included in:
- ResourcesHelper
- Defined in:
- lib/helpers/wallaby/secure_helper.rb
Overview
Secure helper
Instance Method Summary collapse
-
#logout_method(user: wallaby_user, http_method: wallaby_controller.logout_method) ⇒ String, Symbol
Logout method for given user.
-
#logout_path(user: wallaby_user, app: main_app, method_name: wallaby_controller.logout_path) ⇒ String
Logout path for given user.
-
#user_portrait(user: wallaby_user, method_name: wallaby_controller.email_method) ⇒ String
Image portrait for given user.
Instance Method Details
#logout_method(user: wallaby_user, http_method: wallaby_controller.logout_method) ⇒ String, Symbol
Logout method for given user
45 46 47 48 49 50 51 52 53 |
# File 'lib/helpers/wallaby/secure_helper.rb', line 45 def logout_method(user: wallaby_user, http_method: wallaby_controller.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: wallaby_user, app: main_app, method_name: wallaby_controller.logout_path) ⇒ String
Logout path for given user
30 31 32 33 34 35 36 37 38 |
# File 'lib/helpers/wallaby/secure_helper.rb', line 30 def logout_path(user: wallaby_user, app: main_app, method_name: wallaby_controller.logout_path) method_name ||= if defined? ::Devise scope = ::Devise::Mapping.find_scope! user "destroy_#{scope}_session_path" end app.try method_name if method_name end |
#user_portrait(user: wallaby_user, method_name: wallaby_controller.email_method) ⇒ String
Image portrait for given user.
-
if email is present, a gravatar image tag will be returned
-
otherwise, an user icon will be returned
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/helpers/wallaby/secure_helper.rb', line 13 def user_portrait(user: wallaby_user, method_name: wallaby_controller.email_method) method_name ||= user.methods.grep(/email/i).min || :email email = user.try method_name return fa_icon 'user' if email.blank? image_tag( "#{request.protocol}www.gravatar.com/avatar/#{::Digest::MD5.hexdigest email.downcase}", # rubocop:disable Fips/MD5 class: 'user' ) end |