Skip to content

Commit 3878e14

Browse files
author
React-Admin CI
committed
Avoid calling the dataProvider for each canAccess calls
1 parent 800f93a commit 3878e14

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

examples/crm/src/providers/fakerest/authProvider.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,8 @@ export const authProvider: AuthProvider = {
5757
const localUser = userItem ? (JSON.parse(userItem) as Sale) : null;
5858
if (!localUser) return false;
5959

60-
// Get the matching sale
61-
const { data } = await dataProvider.getOne<Sale>('sales', {
62-
id: localUser.id,
63-
});
64-
if (!data) return false;
65-
6660
// Compute access rights from the sale role
67-
const role = data.administrator ? 'admin' : 'user';
61+
const role = localUser.administrator ? 'admin' : 'user';
6862
return canAccess(role, params);
6963
},
7064
getIdentity: () => {

0 commit comments

Comments
 (0)