Skip to content

Commit b7a83d6

Browse files
authored
Merge pull request #77 from techulus/develop
Fix team invites
2 parents e82ea7f + 03c61c2 commit b7a83d6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

apps/web/pages/api/teams/invite/accept/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const acceptInvite = async (req: NextApiRequest, res: NextApiResponse) => {
2626
.from("team_invitations")
2727
.select("*")
2828
.eq("id", invite_id)
29-
.eq("email", user.email)
29+
.ilike("email", user.email)
3030
.single();
3131

3232
if (!invite) {

packages/supabase/migrations/16_teams.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ alter table team_invitations add constraint unique_email_team_id unique (email,
6262
alter table team_invitations enable row level security;
6363
create policy "Can view own team invitations." on team_invitations for select using (auth.uid() = inviter_id);
6464
create policy "Can delete own team invitations." on team_invitations for delete using (auth.uid() = inviter_id);
65-
create policy "Can view team invitations." on team_invitations for select using (auth.email() = email);
66-
create policy "Invited users can view teams." on teams for select using (id in (select team_id from team_invitations where email = auth.email()));
65+
create policy "Can view team invitations." on team_invitations for select using ((lower(auth.email()) = lower(email)));
66+
create policy "Invited users can view teams." on teams for select using ((id IN ( SELECT team_invitations.team_id FROM team_invitations WHERE (lower(team_invitations.email) = lower(auth.email())))));
6767

6868
CREATE TRIGGER set_timestamp
6969
BEFORE UPDATE ON team_invitations

0 commit comments

Comments
 (0)