MCPcopy Create free account
hub / github.com/WebDevSimplified/course-platform / getCurrentUser

Function getCurrentUser

src/services/clerk.ts:11–28  ·  view source on GitHub ↗
({ allData = false } = {})

Source from the content-addressed store, hash-verified

9const client = await clerkClient()
10
11export async function getCurrentUser({ allData = false } = {}) {
12 const { userId, sessionClaims, redirectToSignIn } = await auth()
13
14 if (userId != null && sessionClaims.dbId == null) {
15 redirect("/api/clerk/syncUsers")
16 }
17
18 return {
19 clerkUserId: userId,
20 userId: sessionClaims?.dbId,
21 role: sessionClaims?.role,
22 user:
23 allData && sessionClaims?.dbId != null
24 ? await getUser(sessionClaims.dbId)
25 : undefined,
26 redirectToSignIn,
27 }
28}
29
30export function syncClerkUserMetadata(user: {
31 id: string

Callers 15

createProductFunction · 0.90
updateProductFunction · 0.90
deleteProductFunction · 0.90
createCourseFunction · 0.90
updateCourseFunction · 0.90
deleteCourseFunction · 0.90
refundPurchaseFunction · 0.90
createLessonFunction · 0.90
updateLessonFunction · 0.90
deleteLessonFunction · 0.90
updateLessonOrdersFunction · 0.90

Calls 1

getUserFunction · 0.70

Tested by

no test coverage detected