mirror of
https://github.com/bartvdbraak/omnidash.git
synced 2025-04-27 15:31:21 +00:00
feat: Auth library for Tenant and User ID
This commit is contained in:
parent
6ea6c3e317
commit
130a4932e6
1 changed files with 12 additions and 0 deletions
12
lib/auth.ts
Normal file
12
lib/auth.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { auth } from "@clerk/nextjs/app-beta";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
/**
|
||||
* Return the tenant id or a 404 not found page.
|
||||
*
|
||||
* The auth check should already be done at a higher level, and we're just returning 404 to make typescript happy.
|
||||
*/
|
||||
export function getTenantId(): string {
|
||||
const { userId, orgId } = auth();
|
||||
return orgId ?? userId ?? notFound();
|
||||
}
|
Loading…
Reference in a new issue