mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
🧪 refactor(isDomainAllowed): change directory, add tests (#2539)
This commit is contained in:
parent
099aa9dead
commit
11d5e232b3
4 changed files with 84 additions and 63 deletions
24
api/server/services/isDomainAllowed.js
Normal file
24
api/server/services/isDomainAllowed.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue