From c28f5a71b86dcf0bf5cc3f270940b84352fb2266 Mon Sep 17 00:00:00 2001 From: fzaninotto Date: Mon, 28 Oct 2024 14:11:57 +0100 Subject: [PATCH] Fix `authProvider.getPermissions()` should not throw error when not logged in ## Problem The current setup disallows unauthenticated custom routes: the user is redirected to login. ## Solution If no user is logged in, `getPermissions` should return `undefined` instead of redirecting to login. --- packages/ra-supabase-core/src/authProvider.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ra-supabase-core/src/authProvider.ts b/packages/ra-supabase-core/src/authProvider.ts index bcaef4f..d08622a 100644 --- a/packages/ra-supabase-core/src/authProvider.ts +++ b/packages/ra-supabase-core/src/authProvider.ts @@ -173,10 +173,10 @@ export const supabaseAuthProvider = ( const { data, error } = await client.auth.getUser(); if (error) { - throw error; + return; } if (data.user == null) { - return undefined; + return; } if (typeof getPermissions === 'function') {