Skip to content

Commit

Permalink
authProvider.getPermissions should leave early if there is no permiss…
Browse files Browse the repository at this point in the history
…ions policy
  • Loading branch information
fzaninotto committed Oct 29, 2024
1 parent 2947e85 commit 420b79e
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions packages/ra-supabase-core/src/authProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,33 +157,27 @@ export const supabaseAuthProvider = (
return Promise.resolve();
},
async getPermissions() {
if (
window.location.pathname === '/set-password' ||
window.location.hash.includes('#/set-password')
) {
if (typeof getPermissions !== 'function') {
return;
}
// Users are on the forgot-password page, nothing to do
// No permissions when users are on the set-password page
// or on the forgot-password page.
if (
window.location.pathname === '/set-password' ||
window.location.hash.includes('#/set-password') ||
window.location.pathname === '/forgot-password' ||
window.location.hash.includes('#/forgot-password')
) {
return;
}

const { data, error } = await client.auth.getUser();
if (error) {
return;
}
if (data.user == null) {
if (error || data.user == null) {
return;
}

if (typeof getPermissions === 'function') {
const permissions = await getPermissions(data.user);
return permissions;
}
return undefined;
const permissions = await getPermissions(data.user);
return permissions;
},
};

Expand Down

0 comments on commit 420b79e

Please sign in to comment.