Simplify session context usage
Most cases were preventing some requests from getting triggered. However, this is not necessary anymore since with 6636cc66b1, this is handled globally now
This commit is contained in:
@@ -61,6 +61,12 @@ export class AuthManager {
|
||||
};
|
||||
}
|
||||
|
||||
static useIsAuthenticated(): boolean {
|
||||
const { isAuthRequired, accessToken, refreshToken } = AuthManager.useSession();
|
||||
|
||||
return !isAuthRequired || (isAuthRequired && (!!accessToken || !!refreshToken));
|
||||
}
|
||||
|
||||
static isAuthInitialized(): boolean {
|
||||
return AuthManager.authInitialized;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export const LoginPage = () => {
|
||||
const { t } = useTranslation();
|
||||
const { setOverride } = useNavBarContext();
|
||||
const navigate = useNavigate();
|
||||
const { isAuthRequired, accessToken, refreshToken } = AuthManager.useSession();
|
||||
const isAuthenticated = AuthManager.useIsAuthenticated();
|
||||
|
||||
const [redirect] = useQueryParam(SearchParam.REDIRECT, StringParam);
|
||||
const [loginUser, { loading: isLoading }] = requestManager.useLoginUser();
|
||||
@@ -38,8 +38,6 @@ export const LoginPage = () => {
|
||||
const [username, setUsername] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
|
||||
const isAuthenticated = !isAuthRequired || (isAuthRequired && !!accessToken && !!refreshToken);
|
||||
|
||||
const doLogin = async () => {
|
||||
try {
|
||||
const { data } = await loginUser({ variables: { username, password } });
|
||||
|
||||
Reference in New Issue
Block a user