🧪 refactor(isDomainAllowed): change directory, add tests (#2539)

This commit is contained in:
Marco Beretta 2024-04-25 19:14:07 +02:00 committed by GitHub
parent 099aa9dead
commit 11d5e232b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 84 additions and 63 deletions

View 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;