Skip to content

Commit 2962a11

Browse files
cstocktonChris Stockton
andauthored
fix: use gotrue_id for member search and partition (supabase#37418)
It is possible to have multiple emails from different providers, a common example being SSO users. The user flow being: 1) Sign up with email using [email protected] 2) Upgrade to teams or enterprise 3) Enable SSO for the Org using domain company.local 4) Sign in with [email protected] 5) The SSO provider now handles the login, assigning new gotrue_id but uses the same primary_email 6) View the teams members and one will be omitted This change fixes the case above so that both users are displayed. It also uses the gotrue_id to ensure that the "You" badge displays the correct user. Co-authored-by: Chris Stockton <[email protected]>
1 parent 32c3eeb commit 2962a11

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

apps/studio/components/interfaces/Organization/TeamSettings/MemberRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export const MemberRow = ({ member }: MemberRowProps) => {
8888
/>
8989
<div className="flex item-center gap-x-2">
9090
<p className="text-foreground-light truncate">{member.primary_email}</p>
91-
{member.primary_email === profile?.primary_email && <Badge color="scale">You</Badge>}
91+
{member.gotrue_id === profile?.gotrue_id && <Badge color="scale">You</Badge>}
9292
</div>
9393

9494
{(member.metadata as any)?.origin && (

apps/studio/components/interfaces/Organization/TeamSettings/MembersView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ const MembersView = ({ searchString }: MembersViewProps) => {
5454

5555
const [[user], otherMembers] = partition(
5656
filteredMembers,
57-
(m) => m.primary_email === profile?.primary_email
57+
(m) => m.gotrue_id === profile?.gotrue_id
5858
)
5959
const sortedMembers = otherMembers.sort((a, b) =>
6060
(a.primary_email ?? '').localeCompare(b.primary_email ?? '')
6161
)
6262

63-
const userMember = members.find((m) => m.primary_email === profile?.primary_email)
63+
const userMember = members.find((m) => m.gotrue_id === profile?.gotrue_id)
6464
const orgScopedRoleIds = (roles?.org_scoped_roles ?? []).map((r) => r.id)
6565
const isOrgScopedRole = orgScopedRoleIds.includes(userMember?.role_ids?.[0] ?? -1)
6666

0 commit comments

Comments
 (0)