module Wallaby::SecureHelper
Secure helper
Public Instance Methods
logout_method(user = wallaby_user)
click to toggle source
Logout method for given user @see Wallaby::Configuration::Security#logout_method
@param user [Object] @return [String, Symbol] http method to log out
# File lib/helpers/wallaby/secure_helper.rb, line 44 def logout_method(user = wallaby_user) http_method = 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 = wallaby_user, app = main_app)
click to toggle source
Logout path for given user @see Wallaby::Configuration::Security#logout_path
@param user [Object] @param app [Object] @return [String] URL to log out
# File lib/helpers/wallaby/secure_helper.rb, line 30 def logout_path(user = wallaby_user, app = main_app) path = security.logout_path path ||= if defined? ::Devise scope = ::Devise::Mapping.find_scope! user "destroy_#{scope}_session_path" end try_to app, path end
user_portrait(user = wallaby_user)
click to toggle source
Image portrait for given user.
-
if email is present, a gravatar image tag will be returned
-
otherwise, an user icon will be returned
@param user [Object] @return [String] IMG or I element
# File lib/helpers/wallaby/secure_helper.rb, line 12 def user_portrait(user = wallaby_user) email_method = security.email_method || :email email = try_to user, 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: 'user' else fa_icon 'user' end end