File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
components/login/keycloak Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 1- import { AuthProvider } from "react-admin" ;
1+ import { AuthProvider , HttpError } from "react-admin" ;
22
33import { getURL } from "@/dataProvider/utils" ;
44
@@ -18,7 +18,11 @@ const authProvider: AuthProvider = {
1818 return fetch ( getURL ( "/v1/auth/token" ) , requestOptions )
1919 . then ( ( response ) => {
2020 if ( response . status < 200 || response . status >= 300 ) {
21- throw new Error ( response . statusText ) ;
21+ throw new HttpError (
22+ response . statusText ,
23+ response . status ,
24+ response . body ,
25+ ) ;
2226 }
2327 return response . json ( ) ;
2428 } )
@@ -37,12 +41,12 @@ const authProvider: AuthProvider = {
3741 const status = error . status ;
3842 if ( status === 401 ) {
3943 localStorage . removeItem ( "token" ) ;
40- throw new Error ( error . statusText ) ;
44+ throw error ;
4145 }
4246 return Promise . resolve ( ) ;
4347 } ,
4448 checkAuth : ( ) =>
45- localStorage . getItem ( "username " ) ? Promise . resolve ( ) : Promise . reject ( ) ,
49+ localStorage . getItem ( "token " ) ? Promise . resolve ( ) : Promise . reject ( ) ,
4650 getPermissions : ( ) => Promise . resolve ( ) ,
4751 getIdentity : ( ) => {
4852 const user = localStorage . getItem ( "username" ) ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { useLocation } from "react-router-dom";
44import { CircularProgress } from "@mui/material" ;
55
66import { getURL } from "@/dataProvider/utils" ;
7+ import { HttpError } from "react-admin" ;
78
89const KeycloakAuthCallback = ( ) => {
910 const params = useLocation ( ) ;
@@ -18,7 +19,11 @@ const KeycloakAuthCallback = () => {
1819 fetch ( url . toString ( ) , requestOptions )
1920 . then ( ( response ) => {
2021 if ( response . status < 200 || response . status >= 300 ) {
21- throw new Error ( response . statusText ) ;
22+ throw new HttpError (
23+ response . statusText ,
24+ response . status ,
25+ response . body ,
26+ ) ;
2227 }
2328 window . location . href = "/" ;
2429 } )
You can’t perform that action at this time.
0 commit comments