diff --git a/package-lock.json b/package-lock.json index 6b820c8..57d4d66 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "ccashfrontend", "version": "1.0.0", "license": "ISC", "dependencies": { diff --git a/routes/settings.js b/routes/settings.js index aa49a31..9028f79 100644 --- a/routes/settings.js +++ b/routes/settings.js @@ -49,8 +49,11 @@ module.exports = function (fastify, opts, done) { preValidation: [validate], }, async function (req, res) { + let { attempt, new_pass, password2 } = req.body; let patch; + + if (attempt == undefined) { attempt = ""; } else if (!new_pass || !password2) { @@ -64,16 +67,20 @@ module.exports = function (fastify, opts, done) { res.redirect("/settings"); } else { try { + let name = req.session.get("user"); + let auth = btoa(`${name}:${attempt}`); + auth = `Basic ${auth}`; patch = await got.patch(`${api}user/change_password`, { headers: { Authorization: auth, Accept: "application/json", }, json: { - new_pass: new_pass, + pass: new_pass, }, }); } catch (e) { + console.log(e) req.session.set("errors", `${e.response.body}`); console.log(e.response.body); } @@ -100,6 +107,7 @@ module.exports = function (fastify, opts, done) { preValidation: [validate], }, async function (req, res) { + let { password, password2 } = req.body; let del; if (!password || !password2) {