Skip to content

Commit

Permalink
feat: allow anon to see all profiles
Browse files Browse the repository at this point in the history
Signed-off-by: Raphael Arce <[email protected]>
  • Loading branch information
raphael-arce committed Oct 11, 2024
1 parent 5e6e908 commit 3f03928
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
create policy "Enable read access for all users"
on "public"."profiles"
as PERMISSIVE
for SELECT
to public
using (true);
8 changes: 4 additions & 4 deletions tests/profiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ describe("profiles table", () => {
await deleteUsers([users.userId1, users.userId2]);
});

it("should return no profiles when user is not logged in", async () => {
it("should return all profiles when user is not logged in", async () => {
const { data, error } = await supabaseAnonClient
.from("profiles")
.select("*");
expect(error).toBeNull();
expect(data).toBeDefined();
expect(data!.length).toBe(0);
expect(data!.length).toBe(2);
});

it("should return user's own profile when user is logged in", async () => {
it("should return all profiles when user is logged in", async () => {
const { data: data1, error: error1 } =
await supabaseAnonClient.auth.signInWithPassword({
email: "[email protected]",
Expand All @@ -38,6 +38,6 @@ describe("profiles table", () => {
.select("*");
expect(error).toBeNull();
expect(data).toBeDefined();
expect(data!.length).toBe(1);
expect(data!.length).toBe(2);
});
});

0 comments on commit 3f03928

Please sign in to comment.