File tree Expand file tree Collapse file tree 1 file changed +8
-13
lines changed
Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { authActionClient } from '@/lib/clients/action'
88import { returnServerError } from '@/lib/utils/action'
99import { logError } from '@/lib/clients/logger'
1010import { ERROR_CODES } from '@/configs/logs'
11+ import { checkUserTeamAuthorization } from '@/lib/utils/server'
1112
1213const GetTeamMembersSchema = z . object ( {
1314 teamId : z . string ( ) . uuid ( ) ,
@@ -20,19 +21,6 @@ export const getTeamMembers = authActionClient
2021 const { teamId } = parsedInput
2122 const { user } = ctx
2223
23- const { error : userTeamsRelationError } = await supabaseAdmin
24- . from ( 'users_teams' )
25- . select ( '*' )
26- . eq ( 'user_id' , user . id )
27- . eq ( 'team_id' , teamId )
28- . single ( )
29-
30- if ( userTeamsRelationError ) {
31- logError ( ERROR_CODES . SUPABASE , userTeamsRelationError )
32-
33- return returnServerError ( 'User is not authorized to get team members' )
34- }
35-
3624 const { data, error } = await supabaseAdmin
3725 . from ( 'users_teams' )
3826 . select ( '*' )
@@ -42,6 +30,13 @@ export const getTeamMembers = authActionClient
4230 throw error
4331 }
4432
33+ const accessGranted =
34+ data . findIndex ( ( userTeam ) => userTeam . user_id === user . id ) !== - 1
35+
36+ if ( ! accessGranted ) {
37+ return returnServerError ( 'User is not authorized to get team members' )
38+ }
39+
4540 if ( ! data ) {
4641 return [ ]
4742 }
You can’t perform that action at this time.
0 commit comments