Skip to content

Commit

Permalink
refactor(silentcallback): Catch any errors in async playCallbackAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
jafin authored and guillaume-chervet committed Jul 17, 2024
1 parent 8797330 commit f6cf194
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import { OidcClient } from '@axa-fr/oidc-client';
import { ComponentType, useEffect } from 'react';
import { FC, useEffect } from 'react';

const SilentCallbackManager: ComponentType<any> = ({ configurationName }) => {
export interface SilentCallbackProps {
configurationName: string;
}

const SilentCallbackManager: FC<SilentCallbackProps> = ({ configurationName }) => {
useEffect(() => {
const playCallbackAsync = async () => {
const getOidc = OidcClient.get;
const oidc = getOidc(configurationName);
const oidc = OidcClient.get(configurationName);
oidc.silentLoginCallbackAsync();
};
playCallbackAsync();
}, []);

return <></>;
playCallbackAsync().catch(error => {
console.error('Error during silent login callback:', error);
});

}, [configurationName]);

return null;
};

export default SilentCallbackManager;

0 comments on commit f6cf194

Please sign in to comment.