mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
25 lines
511 B
JavaScript
25 lines
511 B
JavaScript
|
|
const getCustomConfig = require('~/server/services/Config/getCustomConfig');
|
||
|
|
|
||
|
|
async function isDomainAllowed(email) {
|
||
|
|
if (!email) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
const domain = email.split('@')[1];
|
||
|
|
|
||
|
|
if (!domain) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
const customConfig = await getCustomConfig();
|
||
|
|
if (!customConfig) {
|
||
|
|
return true;
|
||
|
|
} else if (!customConfig?.registration?.allowedDomains) {
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
return customConfig.registration.allowedDomains.includes(domain);
|
||
|
|
}
|
||
|
|
|
||
|
|
module.exports = isDomainAllowed;
|