Change password fixes

This commit is contained in:
Vincent Fiduccia 2018-01-20 17:56:10 -07:00
parent 6c261cf86f
commit ef6e6e65fb
No known key found for this signature in database
GPG Key ID: 2B29AD6BB2BB2582
2 changed files with 8 additions and 5 deletions

View File

@ -42,9 +42,8 @@ export default Controller.extend({
}, },
complete(success) { complete(success) {
set(this, 'code', null);
if (success) { if (success) {
set(this, 'code', null);
get(this, 'router').replaceWith('authenticated'); get(this, 'router').replaceWith('authenticated');
} }
}, },

View File

@ -17,6 +17,7 @@ export default Component.extend({
user: null, user: null,
confirmBlurred: false, confirmBlurred: false,
serverErrors: null,
didReceiveAttrs() { didReceiveAttrs() {
run.next(function() { run.next(function() {
@ -31,8 +32,9 @@ export default Component.extend({
return !pass || !confirm || pass !== confirm; return !pass || !confirm || pass !== confirm;
}), }),
errors: computed('saveDisabled', 'confirm', 'confirmBlurred', function() { errors: computed('saveDisabled', 'confirm', 'confirmBlurred', 'serverErrors.[]', function() {
let out = []; let out = get(this, 'serverErrors')||[];
if ( get(this, 'confirmBlurred') && get(this, 'confirm') && get(this, 'saveDisabled') ) { if ( get(this, 'confirmBlurred') && get(this, 'confirm') && get(this, 'saveDisabled') ) {
out.push(get(this, 'intl').t('modalEditPassword.mismatch')); out.push(get(this, 'intl').t('modalEditPassword.mismatch'));
} }
@ -50,6 +52,8 @@ export default Component.extend({
const old = get(this, 'currentPassword'); const old = get(this, 'currentPassword');
const neu = get(this, 'password'); const neu = get(this, 'password');
set(this, 'serverErrors', []);
if (typeof get(this, 'overrideSave') === 'function') { if (typeof get(this, 'overrideSave') === 'function') {
this.sendAction('overrideSave', get(this, 'password')); this.sendAction('overrideSave', get(this, 'password'));
// } else if ( false && user.hasAction('setpassword') ) { // } else if ( false && user.hasAction('setpassword') ) {
@ -72,7 +76,7 @@ export default Component.extend({
}).then(() => { }).then(() => {
this.sendAction('complete', user); this.sendAction('complete', user);
}).catch((err) => { }).catch((err) => {
set(this, 'errors', [err]); set(this, 'serverErrors', [err.message]);
this.sendAction('complete', false); this.sendAction('complete', false);
}).finally(() => { }).finally(() => {
cb(); cb();