Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add custom authn/authz (TT-1547) #52

Merged
merged 10 commits into from
Sep 19, 2024
7 changes: 5 additions & 2 deletions src/app/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export const AuthProvider = ({children}: { children: React.ReactNode }) => {
void signIn(codeInParams, redirectUrl).then((token: User) => {
handleIsAuthenticated(token);
router.push('/');
}).catch((e: Error) => {
console.error('Failed to sign in: ', e.message);
handleNotAuthenticated();
});
} else if (user) {
if (user.expires && new Date(user.expires) > new Date()) {
Expand All @@ -53,8 +56,8 @@ export const AuthProvider = ({children}: { children: React.ReactNode }) => {
window.location.assign(`${keycloakConfig.url}/realms/${keycloakConfig.realm}/protocol/openid-connect/auth` +
`?client_id=${keycloakConfig.clientId}&redirect_uri=${currentUrl}&response_type=code&scope=openid`);
}

}, [handleNotAuthenticated, router, user]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Sindrir marked this conversation as resolved.
Show resolved Hide resolved

const handleIsAuthenticated = (newUser: User) => {
if (newUser) {
Expand Down