diff --git a/.gitignore b/.gitignore index 1c4974b..41fdb29 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,4 @@ npm-debug.log* .DS_Store .lighthouseci .vercel +*.hbs diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 21f3596..0000000 --- a/.prettierignore +++ /dev/null @@ -1,7 +0,0 @@ -.next -.lighthouseci -coverage -node_modules -**/workbox-*.js -**/sw.js -*.hbs diff --git a/package.json b/package.json index 3c4d3b6..4fb137f 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "lint:editorconfig": "editorconfig-checker", "lint:markdown": "markdownlint-cli2", "lint:typescript": "eslint \"**/*.{js,jsx,ts,tsx}\" --ignore-path \".gitignore\"", - "lint:prettier": "prettier \".\" --check", + "lint:prettier": "prettier \".\" --check --ignore-path \".gitignore\"", "lint:staged": "lint-staged", "test:unit": "cypress run --component", "test:html-w3c-validator": "start-server-and-test \"start\" \"http://localhost:3000\" \"html-w3c-validator\"", diff --git a/tools/authentication/Authentication.ts b/tools/authentication/Authentication.ts index 4e97dbd..5222eca 100644 --- a/tools/authentication/Authentication.ts +++ b/tools/authentication/Authentication.ts @@ -5,6 +5,7 @@ import { API_URL } from '../api' import { cookies } from '../cookies' import { Tokens } from '.' import { fetchRefreshToken } from './authenticationFromServerSide' +import { clearCache } from '../cache' export class Authentication { public tokens: Tokens @@ -99,7 +100,7 @@ export class Authentication { public signout(): void { cookies.remove('refreshToken') - window.localStorage.clear() + clearCache() window.location.href = '/authentication/signin' } @@ -120,6 +121,7 @@ export class Authentication { } public signin(): void { + clearCache() cookies.set('refreshToken', this.tokens.refreshToken) } } diff --git a/tools/cache.ts b/tools/cache.ts index 2baa15a..355336d 100644 --- a/tools/cache.ts +++ b/tools/cache.ts @@ -14,7 +14,7 @@ export type CacheKey = export const getPaginationCache = ( key: CacheKey ): T[] => { - const cache = localStorage.getItem(key) + const cache = sessionStorage.getItem(key) if (cache != null) { try { const data = JSON.parse(cache) @@ -30,5 +30,9 @@ export const savePaginationCache = ( key: CacheKey, data: T[] ): void => { - localStorage.setItem(key, JSON.stringify(data)) + sessionStorage.setItem(key, JSON.stringify(data)) +} + +export const clearCache = (): void => { + sessionStorage.clear() }