Skip to content

Commit

Permalink
[Upd #126] Add logout feature when logged in with OIDC
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope authored and blcham committed May 18, 2024
1 parent ce43f8d commit 0e3e3d0
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/components/Logout.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import * as React from "react";
import { useEffect } from "react";
import { useContext, useEffect } from "react";
import { User } from "@models/userModel";
import { useLoggedUser } from "@hooks/useLoggedUser";
import { isUsingOidcAuth } from "@utils/OidcUtils";
import { AuthContext } from "@oidc/OidcAuthWrapper";

const Logout = () => {
const [_, setLoggedUser] = useLoggedUser();

const authCtx = useContext(AuthContext);
useEffect(() => {
setLoggedUser({
authenticated: false,
} as User);
if (isUsingOidcAuth()) {
authCtx.logout();
} else {
setLoggedUser({
authenticated: false,
} as User);
}
}, []);

return <div>Logging out!</div>;
Expand Down

0 comments on commit 0e3e3d0

Please sign in to comment.