[FIX] web: edited password fields should not contain '*'

Before this commit, when someone was editing a password, the stored
password may not be the expected one by the user.

Steps to reproduce:

	1. Open "Outgoing Mail Servers" form.
	2. Set a password (e.g. "yop").
	3. Save, then edit.
	4. Add "y" at the end of the password field.

	> Expected value: "yopy"
	> Actual value: "***y"

This is due to the use of the char field formatter, which displays passwords
by replacing the characters with '*'. It is not necessary to do this in edit
mode, because it uses an input field of type 'password'. The browser
automatically hides the value of such inputs.

Any changes on a input field in edit mode uses the value of the input, so the
value of an password input should contain the password, without '*'.

This commit fixes the issue by using the formatter in edit mode for the input
of type 'password'.

Task-ID 1869565
This commit is contained in:
Alexandre Kühn
2018-07-27 15:02:49 +02:00
parent 2b3017974b
commit 4b3588feb2
3 changed files with 46 additions and 12 deletions
@@ -1183,6 +1183,34 @@ QUnit.module('basic_fields', {
form.destroy();
});
QUnit.test('input field: change password value', function (assert) {
assert.expect(4);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form>' +
'<field name="foo" password="True"/>' +
'</form>',
res_id: 1,
});
assert.notOk(form.$('.o_field_char').text() === "yop",
"password field value should not be visible in read mode");
assert.strictEqual(form.$('.o_field_char').text(), "***",
"password field value should be hidden with '*' in read mode");
form.$buttons.find('.o_form_button_edit').click();
assert.strictEqual(form.$('input.o_field_char').attr('type'), 'password',
"password field input should be with type 'password' in edit mode");
assert.strictEqual(form.$('input.o_field_char').val(), 'yop',
"password field input value should be the (non-hidden) password value");
form.destroy();
});
QUnit.module('UrlWidget');
QUnit.test('url widget in form view', function (assert) {