Browse Source

Merge "Allow forms to disable autofill in all browsers" into stable/icehouse

Jenkins 4 years ago
parent
commit
9ad9af4b8d

+ 10
- 2
horizon/templates/horizon/common/_modal_form.html View File

@@ -12,12 +12,20 @@
12 12
   <form id="{% block form_id %}{% endblock %}"
13 13
         ng-controller="{% block ng_controller %}DummyCtrl{% endblock %}"
14 14
         name="{% block form_name %}{% endblock %}"
15
-        autocomplete="{% block autocomplete %}{% endblock %}"
15
+        autocomplete="{% block autocomplete %}{% if form.no_autocomplete %}off{% endif %}{% endblock %}"
16 16
         class="{% block form_class %}{% endblock %}"
17 17
         action="{% block form_action %}{% endblock %}"
18 18
         method="{% block form-method %}POST{% endblock %}"
19 19
         {% if add_to_field %}data-add-to-field="{{ add_to_field }}"{% endif %} {% block form_attrs %}{% endblock %}>{% csrf_token %}
20 20
     <div class="modal-body clearfix">
21
+
22
+    {% comment %}
23
+    These fake fields are required to prevent Chrome v34+ from autofilling form.
24
+    {% endcomment %}
25
+    {% if form.no_autocomplete %}
26
+    <input type="text" name="fake_email" value="" style="display: none" />
27
+    <input type="password" name="fake_password" value="" style="display: none" />
28
+    {% endif %}
21 29
     {% block modal-body %}
22 30
         <fieldset>
23 31
         {% include "horizon/common/_form_fields.html" %}
@@ -28,4 +36,4 @@
28 36
   </form>
29 37
 </div>
30 38
 {% block modal-js %}
31
-{% endblock %}
39
+{% endblock %}

+ 2
- 0
openstack_dashboard/dashboards/admin/users/forms.py View File

@@ -94,6 +94,7 @@ class CreateUserForm(BaseUserForm):
94 94
     project = forms.DynamicChoiceField(label=_("Primary Project"),
95 95
                                        add_item_link=ADD_PROJECT_URL)
96 96
     role_id = forms.ChoiceField(label=_("Role"))
97
+    no_autocomplete = True
97 98
 
98 99
     def __init__(self, *args, **kwargs):
99 100
         roles = kwargs.pop('roles')
@@ -171,6 +172,7 @@ class UpdateUserForm(BaseUserForm):
171 172
         widget=forms.PasswordInput(render_value=False),
172 173
         required=False)
173 174
     project = forms.ChoiceField(label=_("Primary Project"))
175
+    no_autocomplete = True
174 176
 
175 177
     def __init__(self, request, *args, **kwargs):
176 178
         super(UpdateUserForm, self).__init__(request, *args, **kwargs)

Loading…
Cancel
Save