Skip to content

Commit abf1b7b

Browse files
hexaforceclaude
andcommitted
feat(web): add force password change redirect page
Add /auth/force-password-change route that handles the redirect flow for Auth0 password change during login. The page preserves the Auth0 session state across the password change flow so users only need to log in once. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8c34b22 commit abf1b7b

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

  • web/src
    • classic/components/pages/Authentication/ForcePasswordChange
    • services/routing
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { useEffect } from "react";
2+
3+
import Loading from "@reearth/classic/components/atoms/Loading";
4+
import { getAuthInfo } from "@reearth/services/config";
5+
6+
const STORAGE_KEY = "reearth_password_change_state";
7+
8+
const ForcePasswordChangePage: React.FC = () => {
9+
useEffect(() => {
10+
const params = new URLSearchParams(window.location.search);
11+
const ticket = params.get("ticket");
12+
const state = params.get("state");
13+
14+
if (ticket && state) {
15+
// Coming from Auth0 Post-Login Action redirect.
16+
// Save state to sessionStorage so we can resume the login flow after password change.
17+
sessionStorage.setItem(STORAGE_KEY, state);
18+
// Redirect to Auth0's password change page.
19+
window.location.href = ticket;
20+
return;
21+
}
22+
23+
// Coming back from Auth0 password change page (result_url redirect).
24+
const savedState = sessionStorage.getItem(STORAGE_KEY);
25+
if (savedState) {
26+
sessionStorage.removeItem(STORAGE_KEY);
27+
const authInfo = getAuthInfo();
28+
if (authInfo?.auth0Domain) {
29+
// Redirect back to Auth0 to complete the login flow.
30+
window.location.href = `https://${authInfo.auth0Domain}/continue?state=${savedState}`;
31+
return;
32+
}
33+
}
34+
35+
// Fallback: redirect to top page.
36+
window.location.href = "/";
37+
}, []);
38+
39+
return <Loading />;
40+
};
41+
42+
export default ForcePasswordChangePage;

web/src/services/routing/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ const LoginPage = lazy(() => import("@reearth/classic/components/pages/Authentic
2222
const PasswordResetPage = lazy(
2323
() => import("@reearth/classic/components/pages/Authentication/PasswordReset"),
2424
);
25+
const ForcePasswordChangePage = lazy(
26+
() => import("@reearth/classic/components/pages/Authentication/ForcePasswordChange"),
27+
);
2528

2629
const SignupPage = lazy(
2730
() => import("@reearth/classic/components/pages/Authentication/SignupPage"),
@@ -57,6 +60,10 @@ export const AppRoutes = () => {
5760
index: true,
5861
element: <RootPage />,
5962
},
63+
{
64+
path: "auth/force-password-change",
65+
element: <ForcePasswordChangePage />,
66+
},
6067
{
6168
path: "auth/*",
6269
element: <RootPage />,

0 commit comments

Comments
 (0)