Skip to content

Commit 465cc42

Browse files
authored
Merge pull request #3932 from Northeastern-Electric-Racing/3895-Login-Fix
#3895 login redirect fix
2 parents 28cd945 + f979384 commit 465cc42

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/frontend/src/pages/LoginPage/Login.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import { FormEvent, useState } from 'react';
7-
import { useHistory } from 'react-router-dom';
7+
import { Redirect, useHistory } from 'react-router-dom';
88
import { useToggleTheme } from '../../hooks/theme.hooks';
99
import { useAuth } from '../../hooks/auth.hooks';
1010
import { routes } from '../../utils/routes';
@@ -25,8 +25,17 @@ const Login = () => {
2525
const auth = useAuth();
2626
const organizationContext = useOrganization();
2727

28+
if (!auth.user && !auth.triedCurrent) {
29+
auth.signInCurrent();
30+
return <LoadingIndicator />;
31+
}
32+
2833
if (auth.isLoading) return <LoadingIndicator />;
2934

35+
if (auth.user) {
36+
return <Redirect to={routes.HOME} />;
37+
}
38+
3039
/**
3140
* Produce the path of the page redirected from the login page.
3241
* @param queryArgs the query args sent from the login page, containing page, value1, value2, ..., and other args

0 commit comments

Comments
 (0)