This repository was archived by the owner on Jan 29, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
packages/react-contexts/src/session-context Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,16 +51,23 @@ export function InBrowserSessionContextProvider({
5151 } , [ ] )
5252
5353 const logout = useCallback < SessionControllers [ 'logout' ] > ( async ( ) => {
54- const response = await authGuardedFetchers . put ( '/api/users/logout' )
54+ const response = await authGuardedFetchers . put < { redirectUrl : string } > (
55+ '/api/users/logout' ,
56+ )
5557
5658 clearUserState ( )
5759
5860 if ( response === 'NEED_LOGIN' ) {
5961 return
6062 }
6163
62- if ( response . status === 301 || response . status === 302 ) {
63- const redirectLocation = response . headers . get ( 'Location' )
64+ const isNolConnectedUser =
65+ response . ok &&
66+ response . status === 200 &&
67+ ! ! response . parsedBody . redirectUrl
68+
69+ if ( isNolConnectedUser ) {
70+ const redirectLocation = response . parsedBody . redirectUrl
6471
6572 if ( ! redirectLocation ) {
6673 captureHttpError ( response )
@@ -71,6 +78,7 @@ export function InBrowserSessionContextProvider({
7178 const redirectUrl = getRedirectUrl ( redirectLocation )
7279
7380 window . location . href = redirectUrl
81+ return
7482 }
7583
7684 window . location . reload ( )
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ describe('getRedirectUrl', () => {
1010 it ( 'should return redirect url with redirect query string' , ( ) => {
1111 const result = getRedirectUrl ( 'https://example.com' )
1212 expect ( result ) . toBe (
13- `https://example.com?redirect =${ encodeURIComponent (
13+ `https://example.com?redirectUrl =${ encodeURIComponent (
1414 window . location . href ,
1515 ) } `,
1616 )
@@ -19,7 +19,7 @@ describe('getRedirectUrl', () => {
1919 it ( 'should return redirect url with redirect query string and original href query string' , ( ) => {
2020 const result = getRedirectUrl ( 'https://example.com?code=123' )
2121 expect ( result ) . toBe (
22- `https://example.com?code=123&redirect =${ encodeURIComponent (
22+ `https://example.com?code=123&redirectUrl =${ encodeURIComponent (
2323 window . location . href ,
2424 ) } `,
2525 )
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ export function getRedirectUrl(href: string) {
77 const redirectUrl = generateUrl (
88 {
99 query : qs . stringify ( {
10- redirect : currentUrl ,
10+ redirectUrl : currentUrl ,
1111 } ) ,
1212 } ,
1313 href ,
You can’t perform that action at this time.
0 commit comments