mirror of
https://github.com/Expand-sys/ccashfrontend
synced 2025-12-16 23:02:13 +11:00
patch on change password
This commit is contained in:
parent
9d42cd2770
commit
aa05cdadb8
2 changed files with 10 additions and 1 deletions
1
package-lock.json
generated
1
package-lock.json
generated
|
|
@ -5,6 +5,7 @@
|
|||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "ccashfrontend",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue