mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00
feat: ban-user command (#1121)
* feat: ban-user command * clean up code * added duration * fix(package-lock) revert commit
This commit is contained in:
parent
34148885b7
commit
a7b5639da1
3 changed files with 102 additions and 1 deletions
3
api/cache/banViolation.js
vendored
3
api/cache/banViolation.js
vendored
|
@ -47,7 +47,7 @@ const banViolation = async (req, res, errorMessage) => {
|
|||
res.clearCookie('refreshToken');
|
||||
|
||||
const banLogs = getLogStores('ban');
|
||||
const duration = banLogs.opts.ttl;
|
||||
const duration = errorMessage.duration || banLogs.opts.ttl;
|
||||
|
||||
if (duration <= 0) {
|
||||
return;
|
||||
|
@ -55,6 +55,7 @@ const banViolation = async (req, res, errorMessage) => {
|
|||
|
||||
req.ip = removePorts(req);
|
||||
console.log(`[BAN] Banning user ${user_id} @ ${req.ip} for ${duration / 1000 / 60} minutes`);
|
||||
|
||||
const expiresAt = Date.now() + duration;
|
||||
await banLogs.set(user_id, { type, violation_count, duration, expiresAt });
|
||||
await banLogs.set(req.ip, { type, user_id, violation_count, duration, expiresAt });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue