Usage
Usage of library with examples.
Authenticate
import { SHooks } from '@token-public-org/token-sso-react-library';
import type { ReactNode } from 'react';
const { useSSO } = SHooks;
type Props = {
children:ReactNode
}
const SecureGuard = ({children}:Props)=>{
const { authenticated, login, initialized } = useSSO();
// Wait until sso initialized
if(!initialized){
return <p>loading...</p>
}
// If authenticated return children
if(authenticated){
return children;
}
// Else redirect to login page
login({
redirectUri: window.location.href
});
}
export default SecureGuard;Logout
User Details
User Roles
Last updated