File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -175,6 +175,28 @@ export async function GET(
175175 ) ;
176176 }
177177
178+ // Access control: a profile is public only while the user is "looking for a
179+ // team" (isLooking). Otherwise it is private and visible only to admins,
180+ // evaluators, the user themselves, or their own teammates.
181+ const requester = authResult . user ;
182+ const isPrivileged =
183+ requester . role === "admin" || requester . role === "evaluator" ;
184+ const isSelf = requester . uid === user . uid ;
185+ const isTeammate =
186+ ! ! requester . teamCode &&
187+ ! ! user . teamCode &&
188+ requester . teamCode === user . teamCode ;
189+
190+ if ( ! user . isLooking && ! isPrivileged && ! isSelf && ! isTeammate ) {
191+ return NextResponse . json (
192+ {
193+ message : "This profile is private" ,
194+ status : "error" ,
195+ } ,
196+ { status : 403 } ,
197+ ) ;
198+ }
199+
178200 return NextResponse . json ( {
179201 message : "User found" ,
180202 status : "success" ,
You can’t perform that action at this time.
0 commit comments