Skip to content

Commit cb34114

Browse files
committed
[CR] Fix bug: full redirect after login
Authentication changed in #9593. This broke the ability to redirect to a non-React URL after logging in -- which @Isan-Rivkin discovered broke `lakectl login`. Restore the ability to go to the particular route needed under /api/v1. Checked by re-logging-in.
1 parent 802ca66 commit cb34114

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

webui/src/pages/index.jsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import React from "react";
1+
import React, { useEffect } from "react";
22

33
import {
44
BrowserRouter as Router,
55
Routes,
66
Route,
77
Navigate,
8+
useLocation,
89
} from "react-router-dom";
910
import {WithLoginConfigContext} from "../lib/hooks/conf";
1011

@@ -48,6 +49,17 @@ import {WithAppContext} from "../lib/hooks/appContext";
4849
import {AuthProvider} from "../lib/auth/authContext";
4950
import RequiresAuth from "../lib/components/requiresAuth";
5051

52+
// Component to handle browser redirection - to exit the React app.
53+
const Redirect = () => {
54+
const location = useLocation();
55+
// Break out of React to the actual URL - do not use Navigate.
56+
useEffect(() => {
57+
window.location.replace(location.pathname);
58+
}, [location.pathname]);
59+
60+
return <div>Redirecting...</div>;
61+
};
62+
5163
export const IndexPage = () => {
5264
return (
5365
<Router>
@@ -115,7 +127,8 @@ export const IndexPage = () => {
115127
</Route>
116128
</Route>
117129
</Route>
118-
<Route path="*" element={<Navigate to="/repositories" replace/>}/>
130+
<Route path="api/v1/auth/get-token/release-token/*" element={<Redirect />}/>
131+
<Route path="*" element={<Navigate to="/repositories" replace/>}/>
119132
</Route>
120133
<Route path="auth" element={<Layout/>}>
121134
<Route path="login" element={<LoginPage/>}/>

0 commit comments

Comments
 (0)