fix: Roles should be fetched immediately when logging in
@@ -3,6 +3,7 @@ import React, { useCallback, useState } from 'react';
import Link from 'components/Link';
import { StoreAction, useStoreDispatch } from 'contexts/Store';
+import { useFetchMyRoles } from 'hooks/useFetch';
import { paths } from 'routes/utils';
import { login } from 'services/api';
import { updateDetApi } from 'services/apiConfig';
@@ -29,6 +30,7 @@ const STORAGE_KEY_LAST_USERNAME = 'lastUsername';
const DeterminedAuth: React.FC<Props> = ({ canceler }: Props) => {
const storeDispatch = useStoreDispatch();
+ const fetchMyRoles = useFetchMyRoles(canceler);
const [isBadCredentials, setIsBadCredentials] = useState(false);
const [canSubmit, setCanSubmit] = useState(!!storage.get(STORAGE_KEY_LAST_USERNAME));
@@ -49,6 +51,7 @@ const DeterminedAuth: React.FC<Props> = ({ canceler }: Props) => {
type: StoreAction.SetAuth,
value: { isAuthenticated: true, token, user },
});
+ fetchMyRoles();
storage.set(STORAGE_KEY_LAST_USERNAME, creds.username);
} catch (e) {
const isBadCredentialsSync = isLoginFailure(e);
