diff --git a/src/frontend/src/pages/LoginPage/Login.tsx b/src/frontend/src/pages/LoginPage/Login.tsx index e380fedd88..0ee00e5d27 100644 --- a/src/frontend/src/pages/LoginPage/Login.tsx +++ b/src/frontend/src/pages/LoginPage/Login.tsx @@ -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'; @@ -25,8 +25,17 @@ const Login = () => { const auth = useAuth(); const organizationContext = useOrganization(); + if (!auth.user && !auth.triedCurrent) { + auth.signInCurrent(); + return ; + } + if (auth.isLoading) return ; + if (auth.user) { + return ; + } + /** * 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