Skip to content

Commit

Permalink
Merge pull request #270 from fiit-tp-tim20/main
Browse files Browse the repository at this point in the history
token expiry
  • Loading branch information
lubomirsilny authored Apr 23, 2024
2 parents 90ca615 + fe5c5ac commit 45215b7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions apps/saip-fe/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import Spinner from "./utils/Spinner";
import {useNavigate} from "react-router";
function App() {
const token = localStorage.getItem("token");
const currentDate = new Date();
const exp = localStorage.getItem("expiryDate");
// @ts-ignore
const exp_date = new Date(exp)
const [isLoading, setIsLoading] = useState(true);
const [connect, setConnect] = useState('')
const dataWs = useContext(MyContext);
Expand All @@ -34,6 +38,15 @@ function App() {
comm: null,
start: null
});
useEffect(() => {
if (exp_date < currentDate){
console.log("token expired")
localStorage.removeItem("expiryDate")
localStorage.removeItem("token")

}

}, []);
const { sendMessage,
sendJsonMessage,
lastMessage,
Expand Down

0 comments on commit 45215b7

Please sign in to comment.