Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/llms-txt-hub / apps/web/app/api/auth/metadata/route.ts |
| Date | Not specified in source |
| Repository | Janady13/llms-txt-hub |
| Revision | e0f4bf978d4df168369c7601d9c5f5ea89e84377 |
| Branch | main |
| Path or archive member | apps/web/app/api/auth/metadata/route.ts |
| Original SHA-256 | cda1f105165d3d3252b530d76ebd67444514e18866c046e47d6ceff231b03707 |
| Git blob SHA | 96ead9790aef842ac6716658b57320ee3df939a8 |
| Reading-copy SHA-256 | cda1f105165d3d3252b530d76ebd67444514e18866c046e47d6ceff231b03707 |
Recovered source transcript
Download complete source text ↓39 lines · 1.2 KB
import { auth, clerkClient } from '@clerk/nextjs/server'
import { logger } from '@thedaviddias/logging'
import { type NextRequest, NextResponse } from 'next/server'
/**
* Handle POST request to sync user metadata from auth provider
*/
export async function POST(request: NextRequest) {
try {
const { userId } = await auth()
if (!userId) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
}
const body = await request.json()
const { authLevel, canSubmitPR, githubConnected } = body
// Update user's public metadata
const client = await clerkClient()
await client.users.updateUserMetadata(userId, {
publicMetadata: {
authLevel: authLevel ?? 'email_only',
canSubmitPR: canSubmitPR ?? false,
githubConnected: githubConnected ?? false,
lastUpdated: new Date().toISOString()
}
})
return NextResponse.json({ success: true })
} catch (error) {
logger.error(error instanceof Error ? error : new Error(String(error)), {
data: error,
tags: { type: 'api', route: 'auth/metadata' }
})
return NextResponse.json({ error: 'Failed to update metadata' }, { status: 500 })
}
}