fix: rls not allowing invite member

This commit is contained in:
Rotimi Best
2024-09-17 14:48:33 +01:00
parent 27f333fdcf
commit 8a7a9f8370
2 changed files with 22 additions and 13 deletions
@@ -89,19 +89,8 @@
throw 'Unable to create profile';
}
// Update member response
const updateMemberRes = await supabase
.from('organizationmember')
.update({
verified: true,
profile_id: profile.id
})
.match({ email: data.invite.email, organization_id: data.invite.currentOrg?.id });
console.log('Update member response', updateMemberRes);
const res = await supabase.auth.signInWithPassword({
email: data.invite.email,
email: profile.email,
password: fields.password
});
@@ -109,9 +98,19 @@
throw res.error;
}
// Update member response
const updateMemberRes = await supabase
.from('organizationmember')
.update({
verified: true,
profile_id: profile.id
})
.match({ email: profile.email, organization_id: data.invite.currentOrg?.id });
console.log('Update member response', updateMemberRes);
formRef?.reset();
console.log({ path: $currentOrgPath });
return goto($currentOrgPath);
} catch (error) {
if (error instanceof Error) {
@@ -1060,6 +1060,16 @@ to public
using (is_org_admin())
with check (is_org_admin());
create policy "Only user can update their account via email"
on "public"."organizationmember"
as PERMISSIVE
for UPDATE
to public
using (
(select auth.jwt()) ->> 'email' = email
with check (
(select auth.jwt()) ->> 'email' = email
);
create policy "Only auth users can read profile"
on "public"."profile"