Instead of executing write directly, reuse rest.update to fix request object in user before save is empty when reset password. #951
This commit is contained in:
@@ -2,6 +2,7 @@ import { randomString } from '../cryptoUtils';
|
||||
import { inflate } from '../triggers';
|
||||
import AdaptableController from './AdaptableController';
|
||||
import MailAdapter from '../Adapters/Email/MailAdapter';
|
||||
import rest from '../rest';
|
||||
|
||||
var DatabaseAdapter = require('../DatabaseAdapter');
|
||||
var RestWrite = require('../RestWrite');
|
||||
@@ -165,8 +166,8 @@ export class UserController extends AdaptableController {
|
||||
}
|
||||
|
||||
updatePassword(username, token, password, config) {
|
||||
return this.checkResetTokenValidity(username, token).then(() => {
|
||||
return updateUserPassword(username, token, password, this.config);
|
||||
return this.checkResetTokenValidity(username, token).then((user) => {
|
||||
return updateUserPassword(user._id, password, this.config);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -192,12 +193,11 @@ export class UserController extends AdaptableController {
|
||||
}
|
||||
|
||||
// Mark this private
|
||||
function updateUserPassword(username, token, password, config) {
|
||||
var write = new RestWrite(config, Auth.master(config), '_User', {
|
||||
username: username,
|
||||
_perishable_token: token
|
||||
}, {password: password, _perishable_token: null }, undefined);
|
||||
return write.execute();
|
||||
function updateUserPassword(userId, password, config) {
|
||||
return rest.update(config, Auth.master(config), '_User', userId, {
|
||||
password: password,
|
||||
_perishable_token: null
|
||||
});
|
||||
}
|
||||
|
||||
export default UserController;
|
||||
|
||||
Reference in New Issue
Block a user