diff --git a/app/app/components/password-reset.js b/app/app/components/password-reset.js new file mode 100644 index 00000000..2492fb95 --- /dev/null +++ b/app/app/components/password-reset.js @@ -0,0 +1,57 @@ +import Ember from 'ember'; + +const { + isEmpty, + isEqual, + +} = Ember; + +export default Ember.Component.extend({ + password: "", + passwordConfirm: "", + mustMatch: false, + passwordEmpty: computed('passwordError', { + get() { + if (this.get('passwordError')) { + return `error`; + } + + return; + } + }), + confirmEmpty: computed('passwordConfirmError', { + get() { + if (this.get('passwordConfirmError')) { + return `error`; + } + + return; + } + }), + + actions: { + reset() { + let password = this.get('password'); + let passwordConfirm = this.get('passwordConfirm'); + + if (isEmpty(password)) { + Ember.set(this, 'passwordError', true); + return $("#newPassword").focus(); + } + + if (isEmpty(passwordConfirm)) { + Ember.set(this, 'passwordConfirmError', true); + return $("#passwordConfirm").focus(); + } + + if (!isEqual(password, passwordConfirm)) { + $("#newPassword").addClass("error").focus(); + $("#passwordConfirm").addClass("error"); + this.set('mustMatch', true); + return; + } + + this.get('reset')(); + } + } +}); diff --git a/app/app/pods/auth/reset/template.hbs b/app/app/pods/auth/reset/template.hbs index 2f26e5fb..78b551bb 100644 --- a/app/app/pods/auth/reset/template.hbs +++ b/app/app/pods/auth/reset/template.hbs @@ -2,23 +2,5 @@