| const { logger } = require('@librechat/data-schemas'); |
| const { isEmailDomainAllowed } = require('@librechat/api'); |
| const { getAppConfig } = require('~/server/services/Config'); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| const checkDomainAllowed = async (req, res, next) => { |
| try { |
| const email = req?.user?.email; |
| const appConfig = await getAppConfig({ |
| role: req?.user?.role, |
| }); |
|
|
| if (email && !isEmailDomainAllowed(email, appConfig?.registration?.allowedDomains)) { |
| logger.error(`[Social Login] [Social Login not allowed] [Email: ${email}]`); |
| res.redirect('/login'); |
| return; |
| } |
|
|
| next(); |
| } catch (error) { |
| logger.error('[checkDomainAllowed] Error checking domain:', error); |
| res.redirect('/login'); |
| } |
| }; |
|
|
| module.exports = checkDomainAllowed; |
|
|