Add scheduleremendffdfdts wwfgdwwsudfw ddd

This commit is contained in:
yznahmad 2025-06-20 05:00:10 +03:00
parent e9d354fae8
commit 3efb854d0b

View File

@ -4,10 +4,33 @@
* * source : https://mongoosejs.com/docs/6.x/docs/typescript.html * * source : https://mongoosejs.com/docs/6.x/docs/typescript.html
*/ */
export default async function validateAuthToken(authToken : string | undefined) : Promise<boolean | undefined> export default async function validateAuthToken(authToken: string | undefined): Promise<boolean> {
{ try {
let data : { if (!authToken) {
success : boolean, console.warn('No auth token provided');
} = await (await fetch(process.env.NEXT_PUBLIC_API_BASE+"/api/auth?authToken="+authToken)).json() return false;
return data.success }
const apiBase = process.env.NEXT_PUBLIC_API_BASE;
if (!apiBase) {
console.error('NEXT_PUBLIC_API_BASE environment variable is not set');
return false;
}
const url = new URL('/api/auth', apiBase);
url.searchParams.append('authToken', authToken);
const response = await fetch(url.toString());
if (!response.ok) {
console.error('Auth API request failed with status:', response.status);
return false;
}
const data = await response.json();
return !!data?.success;
} catch (error) {
console.error('Error validating auth token:', error);
return false;
}
} }