| | const { isEnabled } = require('@librechat/api'); |
| | const { logger } = require('@librechat/data-schemas'); |
| | const { SystemRoles } = require('librechat-data-provider'); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | const canDeleteAccount = async (req, res, next = () => {}) => { |
| | const { user } = req; |
| | const { ALLOW_ACCOUNT_DELETION = true } = process.env; |
| | if (user?.role === SystemRoles.ADMIN || isEnabled(ALLOW_ACCOUNT_DELETION)) { |
| | return next(); |
| | } else { |
| | logger.error(`[User] [Delete Account] [User cannot delete account] [User: ${user?.id}]`); |
| | return res.status(403).send({ message: 'You do not have permission to delete this account' }); |
| | } |
| | }; |
| |
|
| | module.exports = canDeleteAccount; |
| |
|