Skip to content

Commit

Permalink
Fixes issue with iOS Safari and autofill (#101)
Browse files Browse the repository at this point in the history
No longer re-renders primary auth form on changes to the rememberMe checkbox,
which caused iOS Safari autofill to repopulate the username and prevent the
user from changing their username.

RESOLVES OKTA-98946
  • Loading branch information
rchild-okta committed Aug 26, 2016
1 parent 55aee7f commit ae3eada
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/views/primary-auth/PrimaryAuthForm.js
Expand Up @@ -97,7 +97,14 @@ define([
'label-top': true,
className: 'margin-btm-0',
initialize: function () {
this.listenTo(this.model, 'change:username', this.render);
this.listenTo(this.model, 'change:remember', function (model, val) {
// OKTA-98946: We normally re-render on changes to model values,
// but in this case we will manually update the checkbox due to
// iOS Safari and how it handles autofill - it will autofill the
// form anytime the dom elements are re-rendered, which prevents
// the user from editing their username.
this.$(':checkbox').prop('checked', val).trigger('updateState');
});
}
});
}
Expand Down
11 changes: 11 additions & 0 deletions test/spec/PrimaryAuth_spec.js
Expand Up @@ -904,6 +904,17 @@ function (_, $, Q, OktaAuth, LoginUtil, Okta, Util, PrimaryAuthForm, Beacon,
expect(test.form.rememberMeCheckboxStatus()).toBe('unchecked');
});
});
itp('does not re-render rememberMe checkbox on changes', function () {
Util.mockCookie('ln', 'testuser');
var options = {
'features.rememberMe': true
};
return setup(options).then(function (test) {
var orig = test.form.rememberMeCheckbox().get(0);
test.form.setUsername('new-user');
expect(test.form.rememberMeCheckbox().get(0)).toBe(orig);
});
});
itp('populate username if username is available', function () {
var options = {
'username': 'testuser@ABC.com'
Expand Down

0 comments on commit ae3eada

Please sign in to comment.