2026-04-07 15:42:58 +07:00
|
|
|
import { doc, getDoc } from 'firebase/firestore';
|
|
|
|
|
import { db } from '../client/firebase';
|
2026-02-17 14:30:02 +07:00
|
|
|
|
|
|
|
|
export async function checkAllowAccess(userDomain: string): Promise<boolean> {
|
2026-04-07 15:42:58 +07:00
|
|
|
const docRef = doc(db, 'whitelist', 'allowedDomains');
|
|
|
|
|
const snapshot = await getDoc(docRef);
|
2026-02-17 14:30:02 +07:00
|
|
|
|
2026-04-07 15:42:58 +07:00
|
|
|
if (snapshot.exists()) {
|
|
|
|
|
let domains = snapshot.data();
|
|
|
|
|
// console.log(`domains: ${JSON.stringify(domains)}`);
|
|
|
|
|
return domains['account_email'].includes(userDomain);
|
|
|
|
|
}
|
2026-02-17 14:30:02 +07:00
|
|
|
|
2026-04-07 15:42:58 +07:00
|
|
|
return true;
|
|
|
|
|
}
|