mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-09-14 07:26:59 +08:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
4d666f8280 |
@@ -26,7 +26,7 @@ exports.login = async function (username, password) {
|
||||
// Upgrade the hash to bcrypt
|
||||
if (passwordHash.needRehash(user.password)) {
|
||||
await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
|
||||
passwordHash.generate(password),
|
||||
await passwordHash.generate(password),
|
||||
user.id,
|
||||
]);
|
||||
}
|
||||
|
@@ -1,5 +1,4 @@
|
||||
const fs = require("fs");
|
||||
const fsAsync = fs.promises;
|
||||
const { R } = require("redbean-node");
|
||||
const { setSetting, setting } = require("./util-server");
|
||||
const { log, sleep } = require("../src/util");
|
||||
@@ -708,12 +707,12 @@ class Database {
|
||||
|
||||
/**
|
||||
* Get the size of the database (SQLite only)
|
||||
* @returns {Promise<number>} Size of database
|
||||
* @returns {number} Size of database
|
||||
*/
|
||||
static async getSize() {
|
||||
static getSize() {
|
||||
if (Database.dbConfig.type === "sqlite") {
|
||||
log.debug("db", "Database.getSize()");
|
||||
let stats = await fsAsync.stat(Database.sqlitePath);
|
||||
let stats = fs.statSync(Database.sqlitePath);
|
||||
log.debug("db", stats);
|
||||
return stats.size;
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ class User extends BeanModel {
|
||||
*/
|
||||
static async resetPassword(userID, newPassword) {
|
||||
await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
|
||||
passwordHash.generate(newPassword),
|
||||
await passwordHash.generate(newPassword),
|
||||
userID
|
||||
]);
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class User extends BeanModel {
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async resetPassword(newPassword) {
|
||||
const hashedPassword = passwordHash.generate(newPassword);
|
||||
const hashedPassword = await passwordHash.generate(newPassword);
|
||||
|
||||
await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
|
||||
hashedPassword,
|
||||
|
@@ -5,10 +5,10 @@ const saltRounds = 10;
|
||||
/**
|
||||
* Hash a password
|
||||
* @param {string} password Password to hash
|
||||
* @returns {string} Hash
|
||||
* @returns {Promise<string>} Hash
|
||||
*/
|
||||
exports.generate = function (password) {
|
||||
return bcrypt.hashSync(password, saltRounds);
|
||||
return bcrypt.hash(password, saltRounds);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -674,7 +674,7 @@ let needSetup = false;
|
||||
|
||||
let user = R.dispense("user");
|
||||
user.username = username;
|
||||
user.password = passwordHash.generate(password);
|
||||
user.password = await passwordHash.generate(password);
|
||||
await R.store(user);
|
||||
|
||||
needSetup = false;
|
||||
|
@@ -20,7 +20,7 @@ module.exports.apiKeySocketHandler = (socket) => {
|
||||
checkLogin(socket);
|
||||
|
||||
let clearKey = nanoid(40);
|
||||
let hashedKey = passwordHash.generate(clearKey);
|
||||
let hashedKey = await passwordHash.generate(clearKey);
|
||||
key["key"] = hashedKey;
|
||||
let bean = await APIKey.save(key, socket.userID);
|
||||
|
||||
|
@@ -14,7 +14,7 @@ module.exports.databaseSocketHandler = (socket) => {
|
||||
checkLogin(socket);
|
||||
callback({
|
||||
ok: true,
|
||||
size: await Database.getSize(),
|
||||
size: Database.getSize(),
|
||||
});
|
||||
} catch (error) {
|
||||
callback({
|
||||
|
@@ -51,7 +51,7 @@ exports.initJWTSecret = async () => {
|
||||
jwtSecretBean.key = "jwtSecret";
|
||||
}
|
||||
|
||||
jwtSecretBean.value = passwordHash.generate(genSecret());
|
||||
jwtSecretBean.value = await passwordHash.generate(genSecret());
|
||||
await R.store(jwtSecretBean);
|
||||
return jwtSecretBean;
|
||||
};
|
||||
|
Reference in New Issue
Block a user