fix: fetchMyRoles on login, only if rbac is on
@@ -3,6 +3,7 @@ import React, { useCallback, useState } from 'react';
import Link from 'components/Link';
import { StoreAction, useStoreDispatch } from 'contexts/Store';
+import useFeature from 'hooks/useFeature';
import { useFetchMyRoles } from 'hooks/useFetch';
import { paths } from 'routes/utils';
import { login } from 'services/api';
@@ -33,6 +34,7 @@ const DeterminedAuth: React.FC<Props> = ({ canceler }: Props) => {
const fetchMyRoles = useFetchMyRoles(canceler);
const [isBadCredentials, setIsBadCredentials] = useState(false);
const [canSubmit, setCanSubmit] = useState(!!storage.get(STORAGE_KEY_LAST_USERNAME));
+ const rbacEnabled = useFeature().isOn('rbac');
const onFinish = useCallback(
async (creds: FromValues): Promise<void> => {
@@ -51,7 +53,9 @@ const DeterminedAuth: React.FC<Props> = ({ canceler }: Props) => {
type: StoreAction.SetAuth,
value: { isAuthenticated: true, token, user },
});
+ if (rbacEnabled) {
fetchMyRoles();
+ }
storage.set(STORAGE_KEY_LAST_USERNAME, creds.username);
} catch (e) {
const isBadCredentialsSync = isLoginFailure(e);
