Skip to content

Commit

Permalink
Redirect to root before log out
Browse files Browse the repository at this point in the history
  • Loading branch information
sergesoroka committed Oct 17, 2024
1 parent 000f2bc commit 120c1a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/MenuBar/Header.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
display: flex;
align-items: center;
border-bottom: 1px solid #e2e2e2;
justify-content: space-between;
padding: 0 1rem 0 0;
}

.headerStartScreen {
Expand Down
5 changes: 4 additions & 1 deletion src/MenuBar/LogoBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState } from "react";
import "./Header.css";

import { useKeycloak } from "@react-keycloak/web";
import { useNavigate } from "react-router-dom";

import { Link } from "react-router-dom";
import { useSetIsShosen, useSetUuid } from "../store/store";
Expand All @@ -14,6 +15,7 @@ export default function LogoBar({ startScreen, uuid, setProjectID }) {
);

const { keycloak } = useKeycloak();
const navigate = useNavigate();

const username = keycloak.tokenParsed?.preferred_username
? keycloak.tokenParsed?.preferred_username
Expand All @@ -22,9 +24,11 @@ export default function LogoBar({ startScreen, uuid, setProjectID }) {
const stored_token = localStorage.getItem("token");

const logoutHandle = () => {
navigate("/");
localStorage.removeItem("username");
localStorage.removeItem("token");
localStorage.removeItem("refreshToken");
keycloak.logout();
};
return (
<div className={startScreen ? "headerStartScreen" : "header"}>
Expand All @@ -51,7 +55,6 @@ export default function LogoBar({ startScreen, uuid, setProjectID }) {
{keycloak.authenticated || stored_token ? (
<button
onClick={() => {
keycloak.logout();
logoutHandle();
}}
className="buttonLogin"
Expand Down

0 comments on commit 120c1a4

Please sign in to comment.