Allow control of password autocomplete by flag
This commit is contained in:
parent
53e611c1c0
commit
ed228c4bd7
3 changed files with 16 additions and 5 deletions
|
@ -204,4 +204,14 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# provide input_html for password autocompletion
|
||||||
|
def autocomplete_flag_to_password_html(password_autocomplete)
|
||||||
|
case password_autocomplete
|
||||||
|
when true then {autocomplete: 'on'}
|
||||||
|
when false then {autocomplete: 'off'}
|
||||||
|
when 'store-only' then {autocomplete: 'off', data: {store: 'on'}}
|
||||||
|
else {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
= h(t('.user.title', user: show_user))
|
= h(t('.user.title', user: show_user))
|
||||||
%small= t '.user.since', when: distance_of_time_in_words(Time.now, @current_user.created_on)
|
%small= t '.user.since', when: distance_of_time_in_words(Time.now, @current_user.created_on)
|
||||||
= simple_form_for(@current_user, :url => update_profile_path) do |f|
|
= simple_form_for(@current_user, :url => update_profile_path) do |f|
|
||||||
= render :partial => 'shared/user_form_fields', :locals => {:f => f, :password_autocomplete => false}
|
= render :partial => 'shared/user_form_fields', :locals => {:f => f, :password_autocomplete => 'store-only'}
|
||||||
.form-actions
|
.form-actions
|
||||||
= submit_tag t('ui.save'), class: 'btn'
|
= submit_tag t('ui.save'), class: 'btn'
|
||||||
.span5
|
.span5
|
||||||
|
|
|
@ -3,12 +3,13 @@
|
||||||
= f.input :email
|
= f.input :email
|
||||||
-# need :required because :use_nil option on user model validators break the required mark
|
-# need :required because :use_nil option on user model validators break the required mark
|
||||||
= f.input :nick, required: true if FoodsoftConfig[:use_nick]
|
= f.input :nick, required: true if FoodsoftConfig[:use_nick]
|
||||||
-# you can disable password autocompletion by passing `password_autocomplete: false` to this partial
|
-# You can control password autocompletion by passing `password_autocomplete` to this partial.
|
||||||
|
-# Possible values: undefined/nil, true, false, 'store-only'
|
||||||
-# see also https://github.com/foodcoops/foodsoft/wiki/Form-autocompletion
|
-# see also https://github.com/foodcoops/foodsoft/wiki/Form-autocompletion
|
||||||
- password_autocomplete = nil unless defined?(:password_autocomplete)
|
- password_autocomplete = nil unless defined?(:password_autocomplete)
|
||||||
- passwd_opts = (password_autocomplete.nil? ? {} : {autocomplete: password_autocomplete ? 'on' : 'off', data: {store: 'on'}})
|
- password_html = autocomplete_flag_to_password_html(password_autocomplete)
|
||||||
= f.input :password, :required => f.object.new_record?, input_html: passwd_opts
|
= f.input :password, :required => f.object.new_record?, input_html: password_html
|
||||||
= f.input :password_confirmation, :required => f.object.new_record?, input_html: passwd_opts
|
= f.input :password_confirmation, :required => f.object.new_record?, input_html: password_html
|
||||||
= f.input :phone
|
= f.input :phone
|
||||||
|
|
||||||
= f.simple_fields_for :settings_attributes do |s|
|
= f.simple_fields_for :settings_attributes do |s|
|
||||||
|
|
Loading…
Reference in a new issue