Skip to content

Commit 53e152e

Browse files
committed
Instead of executing write directly, reuse rest.update to fix request object in user before save is empty when reset password. #951
1 parent ee8f85b commit 53e152e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Controllers/UserController.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { randomString } from '../cryptoUtils';
22
import { inflate } from '../triggers';
33
import AdaptableController from './AdaptableController';
44
import MailAdapter from '../Adapters/Email/MailAdapter';
5+
import rest from '../rest';
56

67
var DatabaseAdapter = require('../DatabaseAdapter');
78
var RestWrite = require('../RestWrite');
@@ -165,8 +166,8 @@ export class UserController extends AdaptableController {
165166
}
166167

167168
updatePassword(username, token, password, config) {
168-
return this.checkResetTokenValidity(username, token).then(() => {
169-
return updateUserPassword(username, token, password, this.config);
169+
return this.checkResetTokenValidity(username, token).then((user) => {
170+
return updateUserPassword(user._id, password, this.config);
170171
});
171172
}
172173

@@ -192,12 +193,11 @@ export class UserController extends AdaptableController {
192193
}
193194

194195
// Mark this private
195-
function updateUserPassword(username, token, password, config) {
196-
var write = new RestWrite(config, Auth.master(config), '_User', {
197-
username: username,
198-
_perishable_token: token
199-
}, {password: password, _perishable_token: null }, undefined);
200-
return write.execute();
196+
function updateUserPassword(userId, password, config) {
197+
return rest.update(config, Auth.master(config), '_User', userId, {
198+
password: password,
199+
_perishable_token: null
200+
});
201201
}
202202

203203
export default UserController;

0 commit comments

Comments
 (0)