INNER CODE UNIT · TypeScript
getAuthenticatedUser
raj457036/CopyCat-Clipboard · supabase/functions/manage_sync_devices/index.ts:31
async function getAuthenticatedUser(req: Request) {
const authToken = req.headers.get("Authorization");
const { data: { user }, error } = await getSupabaseClient(authToken).auth.getUser();
return error ? null : user;
}
async function getPlanDeviceLimit(
client: SupabaseClient,
userId: string,
): Promise<number> {
const { data } = await client
.from(SUBSCRIPTION_TABLE)
.select("devices")
.eq("userId", userId)
.maybeSingle();
const configuredLimit = Number(data?.devices);
if (!Number.isFinite(configuredLimit) || configuredLimit <= 0) {