ensures reset password sends back a new user

This commit is contained in:
James
2020-10-01 14:57:59 -04:00
parent 96c1362a5d
commit 3359cd4e9b
5 changed files with 15 additions and 7 deletions

View File

@@ -12,9 +12,9 @@ function resetPassword(collection) {
api: 'GraphQL',
};
const token = await this.operations.collections.auth.resetPassword(options);
const result = await this.operations.collections.auth.resetPassword(options);
return token;
return result;
}
const resetPasswordResolver = resolver.bind(this);

View File

@@ -100,7 +100,8 @@ async function resetPassword(args) {
// 4. Return updated user
// /////////////////////////////////////
return token;
const fullUser = await this.findByID({ collection: collectionConfig.slug, id: user.id });
return { token, user: fullUser };
}
module.exports = resetPassword;

View File

@@ -2,7 +2,7 @@ const httpStatus = require('http-status');
async function resetPassword(req, res, next) {
try {
const token = await this.operations.collections.auth.resetPassword({
const result = await this.operations.collections.auth.resetPassword({
req,
res,
collection: req.collection,
@@ -12,7 +12,8 @@ async function resetPassword(req, res, next) {
return res.status(httpStatus.OK)
.json({
message: 'Password reset successfully.',
token,
token: result.token,
user: result.user,
});
} catch (error) {
return next(error);