chat / api /server /services /isDomainAllowed.js
Zhitomir's picture
chat init
aa2e6af
Raw
History Blame Contribute Delete
511 Bytes
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;