diff --git a/app/app/components/forgot-password.js b/app/app/components/forgot-password.js new file mode 100644 index 00000000..5f21df36 --- /dev/null +++ b/app/app/components/forgot-password.js @@ -0,0 +1,38 @@ +import Ember from 'ember'; + +const { + computed, + isEmpty +} = Ember; + +export default Ember.Component.extend({ + email: "", + sayThanks: false, + emptyEmail: computed('email', 'emptyEmailError', { + get() { + if (isEmpty(this.get('email')) && this.get('emptyEmailError')) { + return `error`; + } + + return; + } + }), + + actions: { + forgot() { + let email = this.get('email'); + + if (isEmpty(email)) { + Ember.set(this, 'emptyEmailError', true); + return $("#email").focus(); + } + + this.get('forgot')(email).then(() => { + Ember.set(this, 'sayThanks', true); + Ember.set(this, 'email', ''); + }).catch((error) => { + let message = error.message; + }); + } + } +}); diff --git a/app/app/pods/auth/forgot/controller.js b/app/app/pods/auth/forgot/controller.js index 96a57ca7..5fa8aa66 100644 --- a/app/app/pods/auth/forgot/controller.js +++ b/app/app/pods/auth/forgot/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 @@ -13,23 +13,10 @@ import Ember from 'ember'; export default Ember.Controller.extend({ userService: Ember.inject.service('user'), - email: "", - sayThanks: false, actions: { - forgot: function () { - var self = this; - var email = this.get('email'); - - if (is.empty(email)) { - $("#email").addClass("error").focus(); - return; - } - - self.set('sayThanks', true); - this.set('email', ''); - - this.get('userService').forgotPassword(email); + forgot: function (email) { + return this.get('userService').forgotPassword(email); } } -}); \ No newline at end of file +}); diff --git a/app/app/pods/auth/forgot/template.hbs b/app/app/pods/auth/forgot/template.hbs index 90ddfdc1..886add5a 100644 --- a/app/app/pods/auth/forgot/template.hbs +++ b/app/app/pods/auth/forgot/template.hbs @@ -3,20 +3,6 @@ Documize diff --git a/app/app/templates/components/forgot-password.hbs b/app/app/templates/components/forgot-password.hbs new file mode 100644 index 00000000..a11c02c9 --- /dev/null +++ b/app/app/templates/components/forgot-password.hbs @@ -0,0 +1,15 @@ +
+ {{#if sayThanks}} +
Thanks. Check your email for instructions.
+ {{else}} +
+ + {{focus-input type="email" value=email id="email" class=emptyEmail}} +
+
+
+ +
+ {{/if}} + {{#link-to 'auth.login'}}Sign In{{/link-to}} +