File tree 3 files changed +16
-16
lines changed
3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,17 @@ const useLogoutIfAccessDenied = (): LogoutIfAccessDenied => {
71
71
authProvider
72
72
. checkAuth ( { } )
73
73
. then ( ( ) => {
74
- notify ( 'ra.notification.logged_out' , 'warning' ) ;
74
+ if ( logoutUser ) {
75
+ notify (
76
+ 'ra.notification.logged_out' ,
77
+ 'warning'
78
+ ) ;
79
+ } else {
80
+ notify (
81
+ 'ra.notification.not_authorized' ,
82
+ 'warning'
83
+ ) ;
84
+ }
75
85
} )
76
86
. catch ( ( ) => { } ) ;
77
87
}
@@ -85,24 +95,11 @@ const useLogoutIfAccessDenied = (): LogoutIfAccessDenied => {
85
95
if ( logoutUser ) {
86
96
logout ( { } , redirectTo ) ;
87
97
} else {
88
- const redirectToParts = redirectTo . split ( '?' ) ;
89
98
const newLocation : LocationDescriptorObject = {
90
- pathname : redirectToParts [ 0 ] ,
99
+ pathname : redirectTo ,
91
100
} ;
92
101
93
- if ( history . location && history . location . pathname ) {
94
- newLocation . state = {
95
- nextPathname : history . location . pathname ,
96
- nextSearch : history . location . search ,
97
- } ;
98
- }
99
-
100
- if ( redirectToParts [ 1 ] ) {
101
- newLocation . search = redirectToParts [ 1 ] ;
102
- }
103
- history . push ( redirectTo ) ;
104
-
105
- return false ;
102
+ history . push ( newLocation ) ;
106
103
}
107
104
108
105
return true ;
Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ const englishMessages: TranslationMessages = {
138
138
'Cannot load the translations for the specified language' ,
139
139
canceled : 'Action cancelled' ,
140
140
logged_out : 'Your session has ended, please reconnect.' ,
141
+ not_authorized : "You're not authorized to access this resource." ,
141
142
} ,
142
143
validation : {
143
144
required : 'Required' ,
Original file line number Diff line number Diff line change @@ -143,6 +143,8 @@ const frenchMessages: TranslationMessages = {
143
143
'Erreur de chargement des traductions pour la langue sélectionnée' ,
144
144
canceled : 'Action annulée' ,
145
145
logged_out : 'Votre session a pris fin, veuillez vous reconnecter.' ,
146
+ not_authorized :
147
+ "Vous n'êtes pas autorisé à accéder à cette ressource." ,
146
148
} ,
147
149
validation : {
148
150
required : 'Ce champ est requis' ,
You can’t perform that action at this time.
0 commit comments