diff --git a/app/app/components/forgot-password.js b/app/app/components/forgot-password.js index 5f21df36..1978104d 100644 --- a/app/app/components/forgot-password.js +++ b/app/app/components/forgot-password.js @@ -32,6 +32,7 @@ export default Ember.Component.extend({ Ember.set(this, 'email', ''); }).catch((error) => { let message = error.message; + console.log(message); }); } } diff --git a/app/app/components/password-reset.js b/app/app/components/password-reset.js index 2492fb95..d89b41b1 100644 --- a/app/app/components/password-reset.js +++ b/app/app/components/password-reset.js @@ -3,6 +3,9 @@ import Ember from 'ember'; const { isEmpty, isEqual, + isPresent, + computed, + set } = Ember; @@ -12,7 +15,8 @@ export default Ember.Component.extend({ mustMatch: false, passwordEmpty: computed('passwordError', { get() { - if (this.get('passwordError')) { + let error = this.get('passwordError'); + if (isPresent(error)) { return `error`; } @@ -21,7 +25,8 @@ export default Ember.Component.extend({ }), confirmEmpty: computed('passwordConfirmError', { get() { - if (this.get('passwordConfirmError')) { + let error = this.get('passwordConfirmError'); + if (isPresent(error)) { return `error`; } @@ -35,23 +40,23 @@ export default Ember.Component.extend({ let passwordConfirm = this.get('passwordConfirm'); if (isEmpty(password)) { - Ember.set(this, 'passwordError', true); + set(this, 'passwordError', "error"); return $("#newPassword").focus(); } if (isEmpty(passwordConfirm)) { - Ember.set(this, 'passwordConfirmError', true); + set(this, 'passwordConfirmError', "error"); return $("#passwordConfirm").focus(); } if (!isEqual(password, passwordConfirm)) { - $("#newPassword").addClass("error").focus(); - $("#passwordConfirm").addClass("error"); - this.set('mustMatch', true); + set(this, 'passwordError', "error"); + set(this, 'passwordConfirmError', "error"); + set(this, 'mustMatch', true); return; } - this.get('reset')(); + this.get('reset')(password); } } }); diff --git a/app/app/pods/auth/reset/controller.js b/app/app/pods/auth/reset/controller.js index de4870a6..37fe2b87 100644 --- a/app/app/pods/auth/reset/controller.js +++ b/app/app/pods/auth/reset/controller.js @@ -1,11 +1,11 @@ // Copyright 2016 Documize Inc. . All rights reserved. // -// This software (Documize Community Edition) is licensed under +// This software (Documize Community Edition) is licensed under // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html // // You can operate outside the AGPL restrictions by purchasing // Documize Enterprise Edition and obtaining a commercial license -// by contacting . +// by contacting . // // https://documize.com @@ -18,31 +18,10 @@ export default Ember.Controller.extend({ mustMatch: false, actions: { - reset() { - let self = this; - let password = this.get('password'); - let passwordConfirm = this.get('passwordConfirm'); - - if (is.empty(password)) { - $("#newPassword").addClass("error").focus(); - return; - } - - if (is.empty(passwordConfirm)) { - $("#passwordConfirm").addClass("error").focus(); - return; - } - - if (is.not.equal(password, passwordConfirm)) { - $("#newPassword").addClass("error").focus(); - $("#passwordConfirm").addClass("error"); - self.set('mustMatch', true); - return; - } - - this.get('userService').resetPassword(self.model, password).then(function (response) { /* jshint ignore:line */ - self.transitionToRoute('auth.login'); + reset(password) { + return this.get('userService').resetPassword(this.model, password).then(() => { /* jshint ignore:line */ + this.transitionToRoute('auth.login'); }); } } -}); \ No newline at end of file +});