File tree 2 files changed +30
-13
lines changed
packages/ra-core/src/auth
2 files changed +30
-13
lines changed Original file line number Diff line number Diff line change @@ -70,11 +70,20 @@ const useLogout = (): Logout => {
70
70
// do not redirect
71
71
return ;
72
72
}
73
- // redirectTo can contain a query string, e.g. '/login?foo=bar'
74
- // we must split the redirectTo to pass a structured location to navigate()
75
- const redirectToParts = (
76
- redirectToFromProvider || redirectTo
77
- ) . split ( '?' ) ;
73
+
74
+ const finalRedirectTo = redirectToFromProvider || redirectTo ;
75
+
76
+ if ( finalRedirectTo ?. startsWith ( 'http' ) ) {
77
+ // absolute link (e.g. https://my.oidc.server/login)
78
+ resetStore ( ) ;
79
+ queryClient . clear ( ) ;
80
+ window . location . href = finalRedirectTo ;
81
+ return finalRedirectTo ;
82
+ }
83
+
84
+ // redirectTo is an internal location that may contain a query string, e.g. '/login?foo=bar'
85
+ // we must split it to pass a structured location to navigate()
86
+ const redirectToParts = finalRedirectTo . split ( '?' ) ;
78
87
const newLocation : Partial < Path > = {
79
88
pathname : redirectToParts [ 0 ] ,
80
89
} ;
Original file line number Diff line number Diff line change @@ -60,10 +60,18 @@ const useLogoutIfAccessDenied = (): LogoutIfAccessDenied => {
60
60
timer = undefined ;
61
61
} , 0 ) ;
62
62
63
+ const redirectTo =
64
+ e && e . redirectTo != null
65
+ ? e . redirectTo
66
+ : error && error . redirectTo
67
+ ? error . redirectTo
68
+ : undefined ;
69
+
63
70
const shouldNotify = ! (
64
71
disableNotification ||
65
72
( e && e . message === false ) ||
66
- ( error && error . message === false )
73
+ ( error && error . message === false ) ||
74
+ redirectTo ?. startsWith ( 'http' )
67
75
) ;
68
76
if ( shouldNotify ) {
69
77
// notify only if not yet logged out
@@ -90,17 +98,17 @@ const useLogoutIfAccessDenied = (): LogoutIfAccessDenied => {
90
98
} )
91
99
. catch ( ( ) => { } ) ;
92
100
}
93
- const redirectTo =
94
- e && e . redirectTo != null
95
- ? e . redirectTo
96
- : error && error . redirectTo
97
- ? error . redirectTo
98
- : undefined ;
99
101
100
102
if ( logoutUser ) {
101
103
logout ( { } , redirectTo ) ;
102
104
} else {
103
- navigate ( redirectTo ) ;
105
+ if ( redirectTo . startsWith ( 'http' ) ) {
106
+ // absolute link (e.g. https://my.oidc.server/login)
107
+ window . location . href = redirectTo ;
108
+ } else {
109
+ // internal location
110
+ navigate ( redirectTo ) ;
111
+ }
104
112
}
105
113
106
114
return true ;
You can’t perform that action at this time.
0 commit comments