mirror of
https://github.com/documize/community.git
synced 2025-07-24 23:59:47 +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', '');
|
Ember.set(this, 'email', '');
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
let message = error.message;
|
let message = error.message;
|
||||||
|
console.log(message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,9 @@ import Ember from 'ember';
|
||||||
const {
|
const {
|
||||||
isEmpty,
|
isEmpty,
|
||||||
isEqual,
|
isEqual,
|
||||||
|
isPresent,
|
||||||
|
computed,
|
||||||
|
set
|
||||||
|
|
||||||
} = Ember;
|
} = Ember;
|
||||||
|
|
||||||
|
@ -12,7 +15,8 @@ export default Ember.Component.extend({
|
||||||
mustMatch: false,
|
mustMatch: false,
|
||||||
passwordEmpty: computed('passwordError', {
|
passwordEmpty: computed('passwordError', {
|
||||||
get() {
|
get() {
|
||||||
if (this.get('passwordError')) {
|
let error = this.get('passwordError');
|
||||||
|
if (isPresent(error)) {
|
||||||
return `error`;
|
return `error`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +25,8 @@ export default Ember.Component.extend({
|
||||||
}),
|
}),
|
||||||
confirmEmpty: computed('passwordConfirmError', {
|
confirmEmpty: computed('passwordConfirmError', {
|
||||||
get() {
|
get() {
|
||||||
if (this.get('passwordConfirmError')) {
|
let error = this.get('passwordConfirmError');
|
||||||
|
if (isPresent(error)) {
|
||||||
return `error`;
|
return `error`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,23 +40,23 @@ export default Ember.Component.extend({
|
||||||
let passwordConfirm = this.get('passwordConfirm');
|
let passwordConfirm = this.get('passwordConfirm');
|
||||||
|
|
||||||
if (isEmpty(password)) {
|
if (isEmpty(password)) {
|
||||||
Ember.set(this, 'passwordError', true);
|
set(this, 'passwordError', "error");
|
||||||
return $("#newPassword").focus();
|
return $("#newPassword").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmpty(passwordConfirm)) {
|
if (isEmpty(passwordConfirm)) {
|
||||||
Ember.set(this, 'passwordConfirmError', true);
|
set(this, 'passwordConfirmError', "error");
|
||||||
return $("#passwordConfirm").focus();
|
return $("#passwordConfirm").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEqual(password, passwordConfirm)) {
|
if (!isEqual(password, passwordConfirm)) {
|
||||||
$("#newPassword").addClass("error").focus();
|
set(this, 'passwordError', "error");
|
||||||
$("#passwordConfirm").addClass("error");
|
set(this, 'passwordConfirmError', "error");
|
||||||
this.set('mustMatch', true);
|
set(this, 'mustMatch', true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('reset')();
|
this.get('reset')(password);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// 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
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -18,31 +18,10 @@ export default Ember.Controller.extend({
|
||||||
mustMatch: false,
|
mustMatch: false,
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
reset() {
|
reset(password) {
|
||||||
let self = this;
|
return this.get('userService').resetPassword(this.model, password).then(() => { /* jshint ignore:line */
|
||||||
let password = this.get('password');
|
this.transitionToRoute('auth.login');
|
||||||
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');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue