Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/frontend/src/pages/LoginPage/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { FormEvent, useState } from 'react';
import { useHistory } from 'react-router-dom';
import { Redirect, useHistory } from 'react-router-dom';
import { useToggleTheme } from '../../hooks/theme.hooks';
import { useAuth } from '../../hooks/auth.hooks';
import { routes } from '../../utils/routes';
Expand All @@ -25,8 +25,17 @@ const Login = () => {
const auth = useAuth();
const organizationContext = useOrganization();

if (!auth.user && !auth.triedCurrent) {
auth.signInCurrent();
return <LoadingIndicator />;
}

if (auth.isLoading) return <LoadingIndicator />;

if (auth.user) {
return <Redirect to={routes.HOME} />;
}

/**
* Produce the path of the page redirected from the login page.
* @param queryArgs the query args sent from the login page, containing page, value1, value2, ..., and other args
Expand Down