Add scheduleregdww5sudfw ddd
This commit is contained in:
parent
f197bc664a
commit
56fa3dddaa
@ -4,33 +4,42 @@
|
|||||||
* * 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> {
|
// export default async function validateAuthToken(authToken: string | undefined): Promise<boolean> {
|
||||||
try {
|
// try {
|
||||||
if (!authToken) {
|
// if (!authToken) {
|
||||||
console.warn('No auth token provided');
|
// console.warn('No auth token provided');
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const apiBase = process.env.NEXT_PUBLIC_API_BASE;
|
// const apiBase = process.env.NEXT_PUBLIC_API_BASE;
|
||||||
if (!apiBase) {
|
// if (!apiBase) {
|
||||||
console.error('NEXT_PUBLIC_API_BASE environment variable is not set');
|
// console.error('NEXT_PUBLIC_API_BASE environment variable is not set');
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const url = new URL('https://irongym.yznapps.com/api/auth', apiBase);
|
// const url = new URL('https://irongym.yznapps.com/api/auth', apiBase);
|
||||||
url.searchParams.append('authToken', authToken);
|
// url.searchParams.append('authToken', authToken);
|
||||||
|
|
||||||
const response = await fetch(url.toString());
|
// const response = await fetch(url.toString());
|
||||||
|
|
||||||
if (!response.ok) {
|
// if (!response.ok) {
|
||||||
console.error('Auth API request failed with status:', response.status);
|
// console.error('Auth API request failed with status:', response.status);
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const data = await response.json();
|
// const data = await response.json();
|
||||||
return !!data?.success;
|
// return !!data?.success;
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
console.error('Error validating auth token:', error);
|
// console.error('Error validating auth token:', error);
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
export default async function validateAuthToken(authToken : string | undefined) : Promise<boolean | undefined>
|
||||||
|
{
|
||||||
|
let data : {
|
||||||
|
success : boolean,
|
||||||
|
} = await (await fetch("https://irongym.yznapps.com/api/auth?authToken="+authToken)).json()
|
||||||
|
return data.success
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user