2024-03-16 08:40:24 +00:00
|
|
|
import 'std/dotenv/load.ts';
|
|
|
|
|
|
2025-05-24 07:24:10 +00:00
|
|
|
import { UserModel } from './models/user.ts';
|
2024-03-16 08:40:24 +00:00
|
|
|
|
|
|
|
|
export async function isSignupAllowed() {
|
|
|
|
|
const areSignupsAllowed = Deno.env.get('CONFIG_ALLOW_SIGNUPS') === 'true';
|
|
|
|
|
|
2025-05-24 07:24:10 +00:00
|
|
|
const areThereAdmins = await UserModel.isThereAnAdmin();
|
2024-03-16 08:40:24 +00:00
|
|
|
|
|
|
|
|
if (areSignupsAllowed || !areThereAdmins) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-04-03 13:02:04 +00:00
|
|
|
|
2025-02-26 17:43:53 +00:00
|
|
|
export function isAppEnabled(app: 'news' | 'notes' | 'photos' | 'expenses') {
|
2024-05-01 08:21:30 +00:00
|
|
|
const enabledApps = (Deno.env.get('CONFIG_ENABLED_APPS') || '').split(',') as typeof app[];
|
|
|
|
|
|
|
|
|
|
return enabledApps.includes(app);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-11 07:09:11 +00:00
|
|
|
export function isCookieDomainAllowed(domain: string) {
|
|
|
|
|
const allowedDomains = (Deno.env.get('CONFIG_ALLOWED_COOKIE_DOMAINS') || '').split(',') as typeof domain[];
|
2025-01-11 07:14:02 +00:00
|
|
|
|
2025-01-11 07:09:11 +00:00
|
|
|
if (allowedDomains.length === 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return allowedDomains.includes(domain);
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-02 07:24:28 +00:00
|
|
|
export function isCookieDomainSecurityDisabled() {
|
|
|
|
|
const isCookieDomainSecurityDisabled = Deno.env.get('CONFIG_SKIP_COOKIE_DOMAIN_SECURITY') === 'true';
|
|
|
|
|
|
|
|
|
|
return isCookieDomainSecurityDisabled;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-08 19:53:28 +00:00
|
|
|
export function isEmailEnabled() {
|
|
|
|
|
const areEmailsAllowed = Deno.env.get('CONFIG_ENABLE_EMAILS') === 'true';
|
|
|
|
|
|
|
|
|
|
return areEmailsAllowed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function isForeverSignupEnabled() {
|
|
|
|
|
const areForeverAccountsEnabled = Deno.env.get('CONFIG_ENABLE_FOREVER_SIGNUP') === 'true';
|
|
|
|
|
|
|
|
|
|
return areForeverAccountsEnabled;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 13:02:04 +00:00
|
|
|
export function getFilesRootPath() {
|
2024-05-01 08:21:30 +00:00
|
|
|
const configRootPath = Deno.env.get('CONFIG_FILES_ROOT_PATH') || '';
|
2024-04-03 13:02:04 +00:00
|
|
|
|
|
|
|
|
const filesRootPath = `${Deno.cwd()}/${configRootPath}`;
|
|
|
|
|
|
|
|
|
|
return filesRootPath;
|
|
|
|
|
}
|