church-website/src/utils/auth.ts
2025-02-10 14:54:43 +01:00

18 lines
No EOL
463 B
TypeScript

import { cookies } from 'next/headers'
/**
* Check if the current user is (trying to be) authenticated by
* checking if the `payload-token` is present.
*
* Warning: DO NOT USE THIS FUNCTION TO SECURE PARTS OF THE APPLICATION
*/
export const isAuthenticated = async (): Promise<boolean> => {
const cookieStore = await cookies();
const token = cookieStore.get("payload-token");
if(typeof token === "undefined") {
return false;
}
return true;
}