Skip to content

Commit

Permalink
[dy] Fix SSO sign in (mage-ai#4794)
Browse files Browse the repository at this point in the history
  • Loading branch information
dy46 authored Mar 20, 2024
1 parent 776c131 commit 595418b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mage_ai/frontend/components/Sessions/SignForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function SignForm({
}) => {
setUser(user);
AuthToken.storeToken(token, () => {
let url: string = '/';
let url: string = `${router.basePath}/`;
const query = queryFromUrl(window.location.href);

if (typeof window !== 'undefined') {
Expand Down
9 changes: 8 additions & 1 deletion mage_ai/frontend/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import api from '@api';
import { isDemo } from '@utils/environment';
import { logUserOS } from '@utils/gtag';

const PATHS_TO_IGNORE_AUTH_CHECK = [
'/sign-in',
'/oauth',
];

const Home = () => {
const router = useRouter();
const completePath = router.asPath;
Expand All @@ -27,7 +32,9 @@ const Home = () => {
}, []);

useEffect(() => {
if (dataStatus) {
if (PATHS_TO_IGNORE_AUTH_CHECK.includes(basePath)) {
router.replace(completePath);
} else if (dataStatus) {
const requireUserAuthentication = dataStatus?.require_user_authentication;
const loggedIn = AuthToken.isLoggedIn();
if (requireUserAuthentication && !loggedIn) {
Expand Down

0 comments on commit 595418b

Please sign in to comment.