Merge pull request #355 from bluewave-labs/fix/token-issuance
Fixed token issue
This commit is contained in:
2 files changed
+4
-4
No files matched your search
@@ -309,11 +309,12 @@ const validateRecoveryTokenController = async (req, res, next) => {
|
|||||||
const resetPasswordController = async (req, res, next) => {
|
const resetPasswordController = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
await newPasswordValidation.validateAsync(req.body);
|
await newPasswordValidation.validateAsync(req.body);
|
||||||
const response = await req.db.resetPassword(req, res);
|
const user = await req.db.resetPassword(req, res);
|
||||||
|
const token = issueToken(user);
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_RESET_PASSWORD,
|
msg: successMessages.AUTH_RESET_PASSWORD,
|
||||||
data: response,
|
data: { user, token },
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
|
|||||||
@@ -220,8 +220,7 @@ const resetPassword = async (req, res) => {
|
|||||||
})
|
})
|
||||||
.select("-password")
|
.select("-password")
|
||||||
.select("-profileImage");
|
.select("-profileImage");
|
||||||
const token = issueToken(userWithoutPassword);
|
return userWithoutPassword;
|
||||||
return { user: userWithoutPassword, token: token };
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(errorMessages.DB_USER_NOT_FOUND);
|
throw new Error(errorMessages.DB_USER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user