mirror of
https://github.com/netbirdio/dashboard.git
synced 2026-01-26 01:21:04 +00:00
Add logging
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user