mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-21 06:02:04 -04:00
add reset password in cli
This commit is contained in:
parent
6f489e7e0f
commit
d0aad3400c
6 changed files with 115 additions and 20 deletions
21
server/model/user.js
Normal file
21
server/model/user.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
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;
|
Loading…
Add table
Add a link
Reference in a new issue