mirror of
https://github.com/documize/community.git
synced 2025-07-24 07:39:43 +02:00
WIP refactor password reset route to use a component
This commit is contained in:
parent
1eff761336
commit
a66fc70ab3
4 changed files with 78 additions and 20 deletions
57
app/app/components/password-reset.js
Normal file
57
app/app/components/password-reset.js
Normal file
|
@ -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')();
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue