hydrate permissionsStore only if user has role (#8893)

This commit is contained in:
Azri Kahar
2021-10-18 23:45:36 +08:00
committed by GitHub
parent 7c205fdec0
commit 69d9e3adfc

View File

@@ -60,11 +60,11 @@ export async function hydrate(stores = useStores()): Promise<void> {
* else.
*/
await userStore.hydrate();
await permissionsStore.hydrate();
const hydratedStores = ['userStore', 'permissionsStore'];
if (userStore.currentUser?.role) {
await permissionsStore.hydrate();
const hydratedStores = ['userStore', 'permissionsStore'];
await Promise.all(stores.filter(({ $id }) => !hydratedStores.includes($id)).map((store) => store.hydrate?.()));
await registerModules();