Skip to content

Commit cfaaf23

Browse files
committed
fixed user change password route
1 parent d4499b9 commit cfaaf23

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

server/user/user.api.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = function (waw) {
2525
auth: waw.config.mail.auth,
2626
});
2727

28-
waw.send = (opts, cb = (resp) => { }) => {
28+
waw.send = (opts, cb = (resp) => {}) => {
2929
transporter.sendMail(
3030
{
3131
from: waw.config.mail.from,
@@ -38,7 +38,7 @@ module.exports = function (waw) {
3838
);
3939
};
4040
} else {
41-
waw.send = () => { };
41+
waw.send = () => {};
4242
}
4343

4444
const set_is = async (email, is) => {
@@ -142,7 +142,7 @@ module.exports = function (waw) {
142142
],
143143
});
144144
};
145-
const new_pin = async (user, cb = () => { }) => {
145+
const new_pin = async (user, cb = () => {}) => {
146146
user.resetPin = Math.floor(Math.random() * (999999 - 100000)) + 100000;
147147

148148
console.log(user.resetPin);
@@ -220,7 +220,12 @@ module.exports = function (waw) {
220220
"/change": async (req, res) => {
221221
const user = await findUser(req.body.email);
222222

223-
if (user && user.resetPin === req.body.resetPin) {
223+
if (
224+
user &&
225+
user.resetPin &&
226+
req.body.code &&
227+
user.resetPin.toString() === req.body.code.toString()
228+
) {
224229
user.password = user.generateHash(req.body.password);
225230

226231
delete user.resetPin;

0 commit comments

Comments
 (0)