Rename PERUSER => PER_USER

b9375ed7ea7b429147e17727586028722b26924f

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +8 -8Showing whitespace changes
server.js+3 -3
@@ -65,7 +65,7 @@ const DEFAULT_WHITELIST = true;
6565const DEFAULT_ACCOUNTS = false;
6666const DEFAULT_CSRF_DISABLED = false;
6767const DEFAULT_BASIC_AUTH = false;
6868const DEFAULT_PERUSER_BASIC_AUTHDEFAULT_PER_USER_BASIC_AUTH = false;
6969
7070const DEFAULT_ENABLE_IPV6 = false;
7171const DEFAULT_ENABLE_IPV4 = true;
@@ -185,7 +185,7 @@ const enableWhitelist = cliArguments.whitelist ?? getConfigValue('whitelistMode'
185185const dataRoot = cliArguments.dataRoot ?? getConfigValue('dataRoot', './data');
186186const disableCsrf = cliArguments.disableCsrf ?? getConfigValue('disableCsrfProtection', DEFAULT_CSRF_DISABLED);
187187const basicAuthMode = cliArguments.basicAuthMode ?? getConfigValue('basicAuthMode', DEFAULT_BASIC_AUTH);
188188const PERUSER_BASIC_AUTHperUserBasicAuth = getConfigValue('perUserBasicAuth', DEFAULT_PERUSER_BASIC_AUTHDEFAULT_PER_USER_BASIC_AUTH);
189189const enableAccounts = getConfigValue('enableUserAccounts', DEFAULT_ACCOUNTS);
190190
191191const uploadsPath = path.join(dataRoot, require('./src/constants').UPLOADS_DIRECTORY);
@@ -758,7 +758,7 @@ const postSetupTasks = async function (v6Failed, v4Failed) {
758758 }
759759
760760 if (basicAuthMode) {
761761 if (!PERUSER_BASIC_AUTHperUserBasicAuth) {
762762 const basicAuthUser = getConfigValue('basicAuthUser', {});
763763 if (!basicAuthUser?.username || !basicAuthUser?.password) {
764764 console.warn(color.yellow('Basic Authentication is enabled, but username or password is not set or empty!'));
src/middleware/basicAuth.js+3 -3
@@ -6,7 +6,7 @@ const { getAllUserHandles, toKey, getPasswordHash } = require('../users.js');
66const { getConfig, getConfigValue } = require('../util.js');
77const storage = require('node-persist');
88
99const PERUSER_BASIC_AUTHPER_USER_BASIC_AUTH = getConfigValue('perUserBasicAuth', false);
1010
1111const unauthorizedResponse = (res) => {
1212 res.set('WWW-Authenticate', 'Basic realm="SillyTavern", charset="UTF-8"');
@@ -31,9 +31,9 @@ const basicAuthMiddleware = async function (request, response, callback) {
3131 .toString('utf8')
3232 .split(':');
3333
3434 if (! PERUSER_BASIC_AUTHPER_USER_BASIC_AUTH && username === config.basicAuthUser.username && password === config.basicAuthUser.password) {
3535 return callback();
3636 } else if (PERUSER_BASIC_AUTHPER_USER_BASIC_AUTH) {
3737 const userHandles = await getAllUserHandles();
3838 for (const userHandle of userHandles) {
3939 if (username == userHandle) {
src/users.js+2 -2
@@ -20,7 +20,7 @@ const KEY_PREFIX = 'user:';
2020const AVATAR_PREFIX = 'avatar:';
2121const ENABLE_ACCOUNTS = getConfigValue('enableUserAccounts', false);
2222const AUTHELIA_AUTH = getConfigValue('autheliaAuth', false);
2323const PERUSER_BASIC_AUTHPER_USER_BASIC_AUTH = getConfigValue('perUserBasicAuth', false);
2424const ANON_CSRF_SECRET = crypto.randomBytes(64).toString('base64');
2525
2626/**
@@ -588,7 +588,7 @@ async function tryAutoLogin(request) {
588588 return true;
589589 }
590590
591591 if (PERUSER_BASIC_AUTHPER_USER_BASIC_AUTH && await basicUserLogin(request)) {
592592 return true;
593593 }
594594 }