mirror of
https://github.com/documize/community.git
synced 2025-07-24 07:39:43 +02:00
Fix password reset problem
This commit is contained in:
parent
a66fc70ab3
commit
ab76137f5c
3 changed files with 20 additions and 35 deletions
|
@ -32,6 +32,7 @@ export default Ember.Component.extend({
|
|||
Ember.set(this, 'email', '');
|
||||
}).catch((error) => {
|
||||
let message = error.message;
|
||||
console.log(message);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -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');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue