@@ -21,6 +21,7 @@ const UpdateCreatorProfileSchema = z.object({
2121 name : z . string ( ) . min ( 1 , 'Name is required' ) . max ( 100 , 'Max 100 characters' ) . optional ( ) ,
2222 profileImageUrl : z . string ( ) . optional ( ) . or ( z . literal ( '' ) ) ,
2323 details : CreatorProfileDetailsSchema . optional ( ) ,
24+ verified : z . boolean ( ) . optional ( ) , // Verification status (super users only)
2425} )
2526
2627// Helper to check if user has permission to manage profile
@@ -97,11 +98,29 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
9798 return NextResponse . json ( { error : 'Profile not found' } , { status : 404 } )
9899 }
99100
100- // Check permissions
101- const canEdit = await hasPermission ( session . user . id , existing [ 0 ] )
102- if ( ! canEdit ) {
103- logger . warn ( `[${ requestId } ] User denied permission to update profile: ${ id } ` )
104- return NextResponse . json ( { error : 'Access denied' } , { status : 403 } )
101+ // Verification changes require super user permission
102+ if ( data . verified !== undefined ) {
103+ const { verifyEffectiveSuperUser } = await import ( '@/lib/templates/permissions' )
104+ const { effectiveSuperUser } = await verifyEffectiveSuperUser ( session . user . id )
105+ if ( ! effectiveSuperUser ) {
106+ logger . warn ( `[${ requestId } ] Non-super user attempted to change creator verification: ${ id } ` )
107+ return NextResponse . json (
108+ { error : 'Only super users can change verification status' } ,
109+ { status : 403 }
110+ )
111+ }
112+ }
113+
114+ // For non-verified updates, check regular permissions
115+ const hasNonVerifiedUpdates =
116+ data . name !== undefined || data . profileImageUrl !== undefined || data . details !== undefined
117+
118+ if ( hasNonVerifiedUpdates ) {
119+ const canEdit = await hasPermission ( session . user . id , existing [ 0 ] )
120+ if ( ! canEdit ) {
121+ logger . warn ( `[${ requestId } ] User denied permission to update profile: ${ id } ` )
122+ return NextResponse . json ( { error : 'Access denied' } , { status : 403 } )
123+ }
105124 }
106125
107126 const updateData : any = {
@@ -111,6 +130,7 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
111130 if ( data . name !== undefined ) updateData . name = data . name
112131 if ( data . profileImageUrl !== undefined ) updateData . profileImageUrl = data . profileImageUrl
113132 if ( data . details !== undefined ) updateData . details = data . details
133+ if ( data . verified !== undefined ) updateData . verified = data . verified
114134
115135 const updated = await db
116136 . update ( templateCreators )
0 commit comments