mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-19 07:44:02 +02:00
Merge branch 'master' into fix/maintenance_drift
This commit is contained in:
commit
6bc92ddbea
11 changed files with 20 additions and 19 deletions
|
@ -26,7 +26,7 @@ exports.login = async function (username, password) {
|
||||||
// Upgrade the hash to bcrypt
|
// Upgrade the hash to bcrypt
|
||||||
if (passwordHash.needRehash(user.password)) {
|
if (passwordHash.needRehash(user.password)) {
|
||||||
await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
|
await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
|
||||||
passwordHash.generate(password),
|
await passwordHash.generate(password),
|
||||||
user.id,
|
user.id,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
const fsAsync = fs.promises;
|
||||||
const { R } = require("redbean-node");
|
const { R } = require("redbean-node");
|
||||||
const { setSetting, setting } = require("./util-server");
|
const { setSetting, setting } = require("./util-server");
|
||||||
const { log, sleep } = require("../src/util");
|
const { log, sleep } = require("../src/util");
|
||||||
|
@ -707,12 +708,12 @@ class Database {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the size of the database (SQLite only)
|
* Get the size of the database (SQLite only)
|
||||||
* @returns {number} Size of database
|
* @returns {Promise<number>} Size of database
|
||||||
*/
|
*/
|
||||||
static getSize() {
|
static async getSize() {
|
||||||
if (Database.dbConfig.type === "sqlite") {
|
if (Database.dbConfig.type === "sqlite") {
|
||||||
log.debug("db", "Database.getSize()");
|
log.debug("db", "Database.getSize()");
|
||||||
let stats = fs.statSync(Database.sqlitePath);
|
let stats = await fsAsync.stat(Database.sqlitePath);
|
||||||
log.debug("db", stats);
|
log.debug("db", stats);
|
||||||
return stats.size;
|
return stats.size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ class User extends BeanModel {
|
||||||
*/
|
*/
|
||||||
static async resetPassword(userID, newPassword) {
|
static async resetPassword(userID, newPassword) {
|
||||||
await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
|
await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
|
||||||
passwordHash.generate(newPassword),
|
await passwordHash.generate(newPassword),
|
||||||
userID
|
userID
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ class User extends BeanModel {
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async resetPassword(newPassword) {
|
async resetPassword(newPassword) {
|
||||||
const hashedPassword = passwordHash.generate(newPassword);
|
const hashedPassword = await passwordHash.generate(newPassword);
|
||||||
|
|
||||||
await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
|
await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
|
||||||
hashedPassword,
|
hashedPassword,
|
||||||
|
|
|
@ -5,10 +5,10 @@ const saltRounds = 10;
|
||||||
/**
|
/**
|
||||||
* Hash a password
|
* Hash a password
|
||||||
* @param {string} password Password to hash
|
* @param {string} password Password to hash
|
||||||
* @returns {string} Hash
|
* @returns {Promise<string>} Hash
|
||||||
*/
|
*/
|
||||||
exports.generate = function (password) {
|
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");
|
let user = R.dispense("user");
|
||||||
user.username = username;
|
user.username = username;
|
||||||
user.password = passwordHash.generate(password);
|
user.password = await passwordHash.generate(password);
|
||||||
await R.store(user);
|
await R.store(user);
|
||||||
|
|
||||||
needSetup = false;
|
needSetup = false;
|
||||||
|
|
|
@ -20,7 +20,7 @@ module.exports.apiKeySocketHandler = (socket) => {
|
||||||
checkLogin(socket);
|
checkLogin(socket);
|
||||||
|
|
||||||
let clearKey = nanoid(40);
|
let clearKey = nanoid(40);
|
||||||
let hashedKey = passwordHash.generate(clearKey);
|
let hashedKey = await passwordHash.generate(clearKey);
|
||||||
key["key"] = hashedKey;
|
key["key"] = hashedKey;
|
||||||
let bean = await APIKey.save(key, socket.userID);
|
let bean = await APIKey.save(key, socket.userID);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ module.exports.databaseSocketHandler = (socket) => {
|
||||||
checkLogin(socket);
|
checkLogin(socket);
|
||||||
callback({
|
callback({
|
||||||
ok: true,
|
ok: true,
|
||||||
size: Database.getSize(),
|
size: await Database.getSize(),
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
callback({
|
callback({
|
||||||
|
|
|
@ -4,7 +4,7 @@ const { sendInfo } = require("../client");
|
||||||
const { checkLogin } = require("../util-server");
|
const { checkLogin } = require("../util-server");
|
||||||
const GameResolver = require("gamedig/lib/GameResolver");
|
const GameResolver = require("gamedig/lib/GameResolver");
|
||||||
const { testChrome } = require("../monitor-types/real-browser-monitor-type");
|
const { testChrome } = require("../monitor-types/real-browser-monitor-type");
|
||||||
const fs = require("fs");
|
const fsAsync = require("fs").promises;
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
let gameResolver = new GameResolver();
|
let gameResolver = new GameResolver();
|
||||||
|
@ -90,7 +90,7 @@ module.exports.generalSocketHandler = (socket, server) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("getPushExample", (language, callback) => {
|
socket.on("getPushExample", async (language, callback) => {
|
||||||
try {
|
try {
|
||||||
checkLogin(socket);
|
checkLogin(socket);
|
||||||
if (!/^[a-z-]+$/.test(language)) {
|
if (!/^[a-z-]+$/.test(language)) {
|
||||||
|
@ -106,13 +106,13 @@ module.exports.generalSocketHandler = (socket, server) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let dir = path.join("./extra/push-examples", language);
|
let dir = path.join("./extra/push-examples", language);
|
||||||
let files = fs.readdirSync(dir);
|
let files = await fsAsync.readdir(dir);
|
||||||
|
|
||||||
for (let file of files) {
|
for (let file of files) {
|
||||||
if (file.startsWith("index.")) {
|
if (file.startsWith("index.")) {
|
||||||
callback({
|
callback({
|
||||||
ok: true,
|
ok: true,
|
||||||
code: fs.readFileSync(path.join(dir, file), "utf8"),
|
code: await fsAsync.readFile(path.join(dir, file), "utf8"),
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ exports.initJWTSecret = async () => {
|
||||||
jwtSecretBean.key = "jwtSecret";
|
jwtSecretBean.key = "jwtSecret";
|
||||||
}
|
}
|
||||||
|
|
||||||
jwtSecretBean.value = passwordHash.generate(genSecret());
|
jwtSecretBean.value = await passwordHash.generate(genSecret());
|
||||||
await R.store(jwtSecretBean);
|
await R.store(jwtSecretBean);
|
||||||
return jwtSecretBean;
|
return jwtSecretBean;
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<span class="fs-4 title">{{ $t("Uptime Kuma") }}</span>
|
<span class="fs-4 title">{{ $t("Uptime Kuma") }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<a v-if="hasNewVersion" target="_blank" href="https://github.com/louislam/uptime-kuma/releases" class="btn btn-info me-3">
|
<a v-if="hasNewVersion" target="_blank" href="https://github.com/louislam/uptime-kuma/releases" class="btn btn-primary me-3">
|
||||||
<font-awesome-icon icon="arrow-alt-circle-up" /> {{ $t("New Update") }}
|
<font-awesome-icon icon="arrow-alt-circle-up" /> {{ $t("New Update") }}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
|
@ -157,12 +157,12 @@
|
||||||
<!-- Admin functions -->
|
<!-- Admin functions -->
|
||||||
<div v-if="hasToken" class="mb-4">
|
<div v-if="hasToken" class="mb-4">
|
||||||
<div v-if="!enableEditMode">
|
<div v-if="!enableEditMode">
|
||||||
<button class="btn btn-info me-2" data-testid="edit-button" @click="edit">
|
<button class="btn btn-primary me-2" data-testid="edit-button" @click="edit">
|
||||||
<font-awesome-icon icon="edit" />
|
<font-awesome-icon icon="edit" />
|
||||||
{{ $t("Edit Status Page") }}
|
{{ $t("Edit Status Page") }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<a href="/manage-status-page" class="btn btn-info">
|
<a href="/manage-status-page" class="btn btn-primary">
|
||||||
<font-awesome-icon icon="tachometer-alt" />
|
<font-awesome-icon icon="tachometer-alt" />
|
||||||
{{ $t("Go to Dashboard") }}
|
{{ $t("Go to Dashboard") }}
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Add table
Reference in a new issue