File tree Expand file tree Collapse file tree
classic/components/pages/Authentication/ForcePasswordChange Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ const LoginPage = lazy(() => import("@reearth/classic/components/pages/Authentic
2222const 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
2629const 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 /> ,
You can’t perform that action at this time.
0 commit comments