|
|
@ -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,10 +30,19 @@ 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({
|
|
|
|
authorizer: myAuthorizer,
|
|
|
|
authorizer: myAuthorizer,
|
|
|
|