mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-10-01 01:25:45 -04:00
requires empty username/password if set disableAuth for basic auth
This commit is contained in:
parent
6f868c9ec3
commit
44c8ca9da8
@ -1,6 +1,8 @@
|
|||||||
const basicAuth = require("express-basic-auth")
|
const basicAuth = require("express-basic-auth")
|
||||||
const passwordHash = require("./password-hash");
|
const passwordHash = require("./password-hash");
|
||||||
const { R } = require("redbean-node");
|
const { R } = require("redbean-node");
|
||||||
|
const { setting } = require("./util-server");
|
||||||
|
const { debug } = require("../src/util");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -28,9 +30,18 @@ exports.login = async function (username, password) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function myAuthorizer(username, password, callback) {
|
function myAuthorizer(username, password, callback) {
|
||||||
|
|
||||||
|
setting("disableAuth").then((result) => {
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
callback(null, true)
|
||||||
|
} else {
|
||||||
exports.login(username, password).then((user) => {
|
exports.login(username, password).then((user) => {
|
||||||
callback(null, user != null)
|
callback(null, user != null)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.basicAuth = basicAuth({
|
exports.basicAuth = basicAuth({
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
const tcpp = require("tcp-ping");
|
const tcpp = require("tcp-ping");
|
||||||
const Ping = require("./ping-lite");
|
const Ping = require("./ping-lite");
|
||||||
const { R } = require("redbean-node");
|
const { R } = require("redbean-node");
|
||||||
|
const { debug } = require("../src/util");
|
||||||
|
|
||||||
exports.tcping = function (hostname, port) {
|
exports.tcping = function (hostname, port) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -45,7 +46,9 @@ exports.setting = async function (key) {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return JSON.parse(value);
|
const v = JSON.parse(value);
|
||||||
|
debug(`Get Setting: ${key}: ${v}`)
|
||||||
|
return v;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user