diff --git a/src/auth/OIDCProvider.tsx b/src/auth/OIDCProvider.tsx index 7d0ea1f..ffdd570 100644 --- a/src/auth/OIDCProvider.tsx +++ b/src/auth/OIDCProvider.tsx @@ -34,7 +34,7 @@ const auth0AuthorityConfig: AuthorityConfiguration = { const onEvent = (configurationName: any, eventName: any, data: any) => { if (process.env.NODE_ENV !== "production") { - //console.info(`oidc:${configurationName}:${eventName}`, data); + console.info(`oidc:${configurationName}:${eventName}`, data); } }; diff --git a/src/auth/SecureProvider.tsx b/src/auth/SecureProvider.tsx index 41cb13c..21d66e0 100644 --- a/src/auth/SecureProvider.tsx +++ b/src/auth/SecureProvider.tsx @@ -1,4 +1,5 @@ import { OidcSecure, useOidc } from "@axa-fr/react-oidc"; +import loadConfig from "@utils/config"; import { usePathname } from "next/navigation"; import * as React from "react"; import { useEffect } from "react"; @@ -6,13 +7,18 @@ import { useEffect } from "react"; type Props = { children: React.ReactNode; }; + +const config = loadConfig(); + export const SecureProvider = ({ children }: Props) => { const { isAuthenticated, login } = useOidc(); const currentPath = usePathname(); useEffect(() => { + console.log("isAuthenticated", isAuthenticated); if (!isAuthenticated) { - login(currentPath); + console.info("Not authenticated, logging in..."); + login(currentPath, { client_id: config.clientId }); } }, [currentPath, isAuthenticated, login]); diff --git a/src/utils/api.tsx b/src/utils/api.tsx index c2495a2..fdc5381 100644 --- a/src/utils/api.tsx +++ b/src/utils/api.tsx @@ -160,11 +160,12 @@ export function useApiErrorHandling(ignoreError = false) { }; return (err: ErrorResponse) => { + console.info("API request error", err); if (err.code == 401 && err.message == "no valid authentication provided") { - return login(currentPath); + return login(currentPath, { client_id: config.clientId }); } if (err.code == 401 && err.message == "token expired") { - return login(currentPath); + return login(currentPath, { client_id: config.clientId }); } if (err.code == 401 && err.message == "token invalid") { return setError(err);