Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Remove likes from localStorage #906

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/web/src/organisms/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const Header = () => {
useEffect((): void => {
if (isUserLoggedIn() && !isTokenValid()) {
logout();
alert("Your session has expired. Please log in again to continue.")
window.location.href = "/";
}
}, []);
Expand Down
7 changes: 6 additions & 1 deletion src/main/web/src/services/AuthService.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import axios from "axios";
import config from "../config/config";
import {CredentialResponse} from "@react-oauth/google";
import {jwtDecode} from "jwt-decode";

export const register = (username: string, email: string, password: string) => {
Expand Down Expand Up @@ -63,6 +62,12 @@ export const logout = (): void => {
localStorage.removeItem("username");
localStorage.removeItem("token");
localStorage.removeItem('userImage');

Object.keys(localStorage)
.filter(x =>
x.includes("_liked_")
).map(
x => localStorage.removeItem(x));
};

export const getAccountId = (): number | null => {
Expand Down
Loading