diff --git a/lib/User.js b/lib/User.js index 6b17bc4..dc73b2f 100644 --- a/lib/User.js +++ b/lib/User.js @@ -66,8 +66,18 @@ class User { 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() {