File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,19 +68,14 @@ const LoginPage = ({
6868 } ) ;
6969 const { mutate : loginUser , isPending : isLoggingIn } = useLogin ( {
7070 onSuccess : async ( data ) => {
71- if ( localNextPath ) {
71+ const redirectUrl = localNextPath || data . redirectUrl || '' ;
72+ if ( redirectUrl . startsWith ( '/' ) ) {
7273 await fetchAuthenticatedUser ( { forceRefresh : true } ) ;
73- setLoginResult ( { success : true , redirectUrl : localNextPath } ) ;
7474 // Hydrate in the background — publishes AUTHENTICATED_USER_CHANGED after
7575 // SPA navigation, so the header picks up the full user profile (avatar, etc.)
7676 hydrateAuthenticatedUser ( ) ;
77- } else if ( data . redirectUrl ?. startsWith ( '/' ) ) {
78- await fetchAuthenticatedUser ( { forceRefresh : true } ) ;
79- setLoginResult ( { success : true , redirectUrl : data . redirectUrl } ) ;
80- hydrateAuthenticatedUser ( ) ;
81- } else {
82- setLoginResult ( { success : true , redirectUrl : data . redirectUrl || '' } ) ;
8377 }
78+ setLoginResult ( { success : true , redirectUrl } ) ;
8479 } ,
8580 onError : ( formattedError ) => {
8681 setErrorCode ( prev => ( {
Original file line number Diff line number Diff line change @@ -110,19 +110,14 @@ const RegistrationPage = (props) => {
110110 const backendRegistrationError = registrationError ;
111111 const registrationMutation = useRegistration ( {
112112 onSuccess : async ( data ) => {
113- if ( localNextPath ) {
113+ const redirectUrl = localNextPath || data . redirectUrl || '' ;
114+ if ( redirectUrl . startsWith ( '/' ) ) {
114115 await fetchAuthenticatedUser ( { forceRefresh : true } ) ;
115- setRegistrationResult ( { ...data , redirectUrl : localNextPath } ) ;
116116 // Hydrate in the background — publishes AUTHENTICATED_USER_CHANGED after
117117 // SPA navigation, so the header picks up the full user profile (avatar, etc.)
118118 hydrateAuthenticatedUser ( ) ;
119- } else if ( data . redirectUrl ?. startsWith ( '/' ) ) {
120- await fetchAuthenticatedUser ( { forceRefresh : true } ) ;
121- setRegistrationResult ( { ...data , redirectUrl : data . redirectUrl } ) ;
122- hydrateAuthenticatedUser ( ) ;
123- } else {
124- setRegistrationResult ( data ) ;
125119 }
120+ setRegistrationResult ( { ...data , redirectUrl } ) ;
126121 setRegistrationError ( { } ) ;
127122 } ,
128123 onError : ( errorData ) => {
You can’t perform that action at this time.
0 commit comments