Module: Decidim::PasswordsHelper
- Defined in:
- app/helpers/decidim/passwords_helper.rb
Instance Method Summary collapse
- #needs_admin_password?(user) ⇒ Boolean
- #old_password_options ⇒ Object
- #password_field_options_for(user) ⇒ Object
Instance Method Details
#needs_admin_password?(user) ⇒ Boolean
49 50 51 52 53 54 |
# File 'app/helpers/decidim/passwords_helper.rb', line 49 def needs_admin_password?(user) return false unless user&.admin? return false unless Decidim.config.admin_password_strong true end |
#old_password_options ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/decidim/passwords_helper.rb', line 37 def help_text = t("devise.passwords.edit.old_password_help").html_safe { autocomplete: "current-password", required: true, label: false, help_text:, placeholder: "••••••" } end |
#password_field_options_for(user) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/helpers/decidim/passwords_helper.rb', line 5 def (user) user = case user when :user Decidim::User.new when :admin Decidim::User.new(admin: true) when String Decidim::User.with_reset_password_token(user) else user end min_length = ::PasswordValidator.minimum_length_for(user) help_text = if needs_admin_password?(user) t("devise.passwords.edit.password_help_admin", minimum_characters: min_length) else t("devise.passwords.edit.password_help", minimum_characters: min_length) end { autocomplete: "new-password", required: true, label: false, help_text:, value: @account&.password, minlength: min_length, maxlength: ::PasswordValidator::MAX_LENGTH, placeholder: "••••••" } end |