mirror of
https://github.com/documize/community.git
synced 2025-07-23 07:09:43 +02:00
WIP refactor forgot password route to use a component
This commit is contained in:
parent
5795c828e2
commit
1eff761336
4 changed files with 59 additions and 33 deletions
38
app/app/components/forgot-password.js
Normal file
38
app/app/components/forgot-password.js
Normal file
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. 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 <sales@documize.com>.
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,20 +3,6 @@
|
|||
<img src="assets/img/logo-color.png" title="Documize" alt="Documize" class="responsive-img" />
|
||||
</div>
|
||||
<div class="login-form">
|
||||
<form {{action 'forgot' on="submit"}}>
|
||||
{{#if sayThanks}}
|
||||
<div class="reset-thanks margin-bottom-30">Thanks. Check your email for instructions.</div>
|
||||
{{else}}
|
||||
<div class="input-control">
|
||||
<label>Email</label>
|
||||
{{focus-input type="email" value=email id="email"}}
|
||||
</div>
|
||||
<div class="clearfix" />
|
||||
<div class="margin-top-10 margin-bottom-20">
|
||||
<button type="submit" class="regular-button button-blue">Reset</button>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#link-to 'auth.login'}}Sign In{{/link-to}}
|
||||
</form>
|
||||
{{forgot-password forgot=(action 'forgot')}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
15
app/app/templates/components/forgot-password.hbs
Normal file
15
app/app/templates/components/forgot-password.hbs
Normal file
|
@ -0,0 +1,15 @@
|
|||
<form {{action 'forgot' on="submit"}}>
|
||||
{{#if sayThanks}}
|
||||
<div class="reset-thanks margin-bottom-30">Thanks. Check your email for instructions.</div>
|
||||
{{else}}
|
||||
<div class="input-control">
|
||||
<label>Email</label>
|
||||
{{focus-input type="email" value=email id="email" class=emptyEmail}}
|
||||
</div>
|
||||
<div class="clearfix" />
|
||||
<div class="margin-top-10 margin-bottom-20">
|
||||
<button type="submit" class="regular-button button-blue">Reset</button>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#link-to 'auth.login'}}Sign In{{/link-to}}
|
||||
</form>
|
Loading…
Add table
Add a link
Reference in a new issue