Closed AlexandraOM closed 4 years ago
removing the object from entries to create a obj instead:
const arrays = body.split('&').map((x) => x.split('=')); let dataObj = { username: arrays[0][1], password: arrays[1][1], }; // const incomingInfo = Object.fromEntries(new URLSearchParams(body)); const username = dataObj.username; const password = dataObj.username; model.getSpecificUser(username).then((user) => { // console.log(user.rows); if (user.rowCount) { const hashedPassword = user.rows[0].password; if (bcryptjs.compareSync(password, hashedPassword)) { const newCookie = jwt.sign(username, secret); response.writeHead(302, { Location: '/', 'Set-Cookie': `login=${newCookie}; HttpOnly`, }); return response.end();
It would be great to get that last test working in for 'check passwords' So if you could put the above bcrypt.compare into a separate function which you just call on in the handlers.
removing the object from entries to create a obj instead: