in source/webapp/src/lib/js/signInModal.js [160:230]
async domNewPasswordInit() {
const formId = 'newPasswordForm';
const newPasswordId = 'newPasswordId';
const retypePasswordId = 'retypePasswordId';
const alertId = 'alertId';
const element = $(`
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">New Password Required</h5>
</div>
<div class="modal-body">
<form id="${formId}">
<div class="form-group">
<label for="${newPasswordId}">New Password</label>
<input type="password" class="form-control" id="${newPasswordId}" placeholder="Password">
</div>
<div class="form-group">
<label for="${retypePasswordId}">Re-type password</label>
<input type="password" class="form-control" id="${retypePasswordId}" placeholder="Password">
</div>
<div class="form-group">
<small>Must contain at least 8 characters, one uppercase, one lowercase, one number, and one special character</small>
</div>
<button type="submit" class="btn btn-secondary">Update</button>
<div class="form-group">
<span id="${alertId}" class="collapse text-danger">Alert message...</span>
</div>
</form>
</div>
</div>
</div>`);
element.appendTo(this.newPasswordModal);
const form = $(`#${formId}`, this.newPasswordModal);
const password01 = $(`#${newPasswordId}`, form);
const password02 = $(`#${retypePasswordId}`, form);
const alertMessage = $(`#${alertId}`, form);
/* password form submit event */
form.off('submit').submit(async (event) => {
try {
event.preventDefault();
if (password01.val() !== password02.val()) {
alertMessage.html('<small>passwords do not match. Please re-enter.</small>').collapse('show');
} else if (!password01.val().match(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&#])[A-Za-z\d@$!%*?&#]{8,}$/)) {
alertMessage.html('<small>password does not meet criteria. Please re-enter.</small>').collapse('show');
} else {
let response;
response = await this.cognito.confirmNewPassword(password01.val());
response = await this.signIn();
this.newPasswordModal.modal('hide');
}
} catch (e) {
e.message = `#passwordForm.submit: ${e.message}`;
console.error(encodeURIComponent(e.message));
}
});
/* reset password fields onHide */
this.newPasswordModal.off('hide.bs.modal').on('hide.bs.modal', () => {
password01.val('');
password02.val('');
alertMessage.html('').collapse('hide');
});
}