1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 22:19:26 +00:00

Implemented User.changePassword

This commit is contained in:
2022-02-14 10:29:58 +00:00
parent e38135cb6c
commit b955609399

View File

@@ -66,8 +66,18 @@ class User {
return await bcrypt.compare(password, this.password); return await bcrypt.compare(password, this.password);
} }
changePassword(password) { async changePassword(password) {
const newPassword = await User.hashPassword(password);
const conn = await new DatabaseConnectionPool();
const sql = `
update ${this.type}
set password = ?
where ${this.type}Id = ?;
`;
await conn.runQuery(sql, [ newPassword, this.id ]);
} }
getPasswordReset() { getPasswordReset() {