You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
559 B
22 lines
559 B
const { BeanModel } = require("redbean-node/dist/bean-model");
|
|
const passwordHash = require("../password-hash");
|
|
const { R } = require("redbean-node");
|
|
|
|
class User extends BeanModel {
|
|
|
|
/**
|
|
* Direct execute, no need R.store()
|
|
* @param newPassword
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async resetPassword(newPassword) {
|
|
await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
|
|
passwordHash.generate(newPassword),
|
|
this.id
|
|
]);
|
|
this.password = newPassword;
|
|
}
|
|
}
|
|
|
|
module.exports = User;
|