Skip to content

Commit

Permalink
fix(supabase): fallback_role_id (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
fouad authored Mar 11, 2024
1 parent 2af38d5 commit a6ef720
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions packages/beta/indent-integration-supabase/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,31 @@ export class SupabaseIntegration
delete res.status.message
}
} else {
// Remove member from organization
await this.FetchSupabase({
method: 'DELETE',
url: `/v0/organizations/${SUPABASE_ORG_ID}/members/${existingMember.gotrue_id}`,
})
console.log('removed from organization')
res.status.code = StatusCode.OK
delete res.status.message
if (resource.labels?.['fallback_role_id']) {
// If there's a fallback role, update the member to that role
await this.FetchSupabase({
method: 'PATCH',
url: `/v0/organizations/${SUPABASE_ORG_ID}/members/${existingMember.gotrue_id}`,
data: {
role_id: parseInt(resource.labels['fallback_role_id'], 10),
},
})
console.log(
'updated role to fallback role',
resource.labels['fallback_role_id']
)
res.status.code = StatusCode.OK
delete res.status.message
} else {
// Remove member from organization
await this.FetchSupabase({
method: 'DELETE',
url: `/v0/organizations/${SUPABASE_ORG_ID}/members/${existingMember.gotrue_id}`,
})
console.log('removed from organization')
res.status.code = StatusCode.OK
delete res.status.message
}
}
}
} catch (err) {
Expand Down

0 comments on commit a6ef720

Please sign in to comment.