fix(config/scripts): Enhance User Creation and Ban Handling, Standardize Imports (#1144)

* chore: use relative imports for scripts

* fix(create-user): newUser.save() now properly awaited, double-check user creation, use relative imports, catch exception

* fix(ban-user): catch exception, handle case where IP is undefined, proper check of user ban on login
This commit is contained in:
Danny Avila 2023-11-06 09:19:43 -05:00 committed by GitHub
parent a2ee57568a
commit 5f3ecef575
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 102 additions and 27 deletions

View file

@ -1,7 +1,7 @@
const connectDb = require('@librechat/backend/lib/db/connectDb');
const connectDb = require('../api/lib/db/connectDb');
const { askQuestion, silentExit } = require('./helpers');
const banViolation = require('../api/cache/banViolation');
const User = require('@librechat/backend/models/User');
const User = require('../api/models/User');
(async () => {
/**
@ -97,3 +97,16 @@ const User = require('@librechat/backend/models/User');
silentExit(0);
})();
process.on('uncaughtException', (err) => {
if (!err.message.includes('fetch failed')) {
console.error('There was an uncaught error:');
console.error(err);
}
if (err.message.includes('fetch failed')) {
return;
} else {
process.exit(1);
}
});