Skip to content

Commit 8764f5d

Browse files
Vonngclaude
andcommitted
fix(web): stop recursive login redirects
An expired session on a deep link bounced through /login and back, accumulating a redirect chain instead of landing on the form once. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent b952a12 commit 8764f5d

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

web-app/src/ProtectedRoutes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const ProtectedRoute = ({ Component }: ProtectedRouteProps) => {
4646

4747
const StorePathAndRedirect = () => {
4848
localStorage.setItem("redirect-path", pathname);
49-
return <Navigate to={{ pathname: `login` }} />;
49+
return <Navigate to={{ pathname: `/login` }} />;
5050
};
5151

5252
useEffect(() => {

web-app/tests/subpath-nginx/test-unauthenticated-user.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17+
import { ClientFunction } from "testcafe";
1718
import * as elements from "../utils/elements";
1819

1920
// Using subpath defined in `MINIO_BROWSER_REDIRECT_URL`
@@ -26,3 +27,21 @@ test("RootUrl redirects to Login Page", async (t) => {
2627
const loginButtonExists = elements.loginButton.exists;
2728
await t.navigateTo(rootUrl).expect(loginButtonExists).ok().wait(2000);
2829
});
30+
31+
test("Deep routes redirect once to Login Page", async (t) => {
32+
const getRedirectState = ClientFunction(() => ({
33+
pathname: window.location.pathname,
34+
redirectPath: window.localStorage.getItem("redirect-path"),
35+
}));
36+
37+
await t
38+
.navigateTo(`${appBaseUrl}/browser`)
39+
.expect(elements.loginButton.exists)
40+
.ok()
41+
.wait(1000)
42+
.expect(getRedirectState())
43+
.eql({
44+
pathname: "/console/subpath/login",
45+
redirectPath: "/browser",
46+
});
47+
});

0 commit comments

Comments
 (0)