mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-24 23:34:03 +00:00
8a92054c2b
* Added JSDoc to eslint rules Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> * Fixed JSDoc eslint errors Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> * Update the check-linters workflow to Node.js 20 --------- Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
32 lines
997 B
JavaScript
32 lines
997 B
JavaScript
const { BeanModel } = require("redbean-node/dist/bean-model");
|
|
const passwordHash = require("../password-hash");
|
|
const { R } = require("redbean-node");
|
|
|
|
class User extends BeanModel {
|
|
/**
|
|
* Reset user password
|
|
* Fix #1510, as in the context reset-password.js, there is no auto model mapping. Call this static function instead.
|
|
* @param {number} userID ID of user to update
|
|
* @param {string} newPassword Users new password
|
|
* @returns {Promise<void>}
|
|
*/
|
|
static async resetPassword(userID, newPassword) {
|
|
await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
|
|
passwordHash.generate(newPassword),
|
|
userID
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Reset this users password
|
|
* @param {string} newPassword Users new password
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async resetPassword(newPassword) {
|
|
await User.resetPassword(this.id, newPassword);
|
|
this.password = newPassword;
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = User;
|