Skip to content

Commit

Permalink
fix: replace sessionStorage with session cookie
Browse files Browse the repository at this point in the history
Because it was found that sessionStorage works differently from session cookie.
  • Loading branch information
Leksat committed Sep 4, 2024
1 parent 498cdd7 commit 1119b5a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@
"devDependencies": {
"@amazeelabs/eslint-config": "1.4.43",
"@octokit/types": "13.5.0",
"@types/js-cookie": "3.0.6",
"@types/node": "18.19.33",
"@types/react": "18.3.1",
"@types/semaphore": "1.1.4",
"js-cookie": "3.0.5",
"typescript": "5.4.5",
"vitest": "1.6.0"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TokenAuthClient } from '@amazeelabs/token-auth-middleware';
import { GitHubBackend } from 'decap-cms-backend-github';
import { Implementation } from 'decap-cms-lib-util';
import Cookies from 'js-cookie';

import { AuthComponent } from './ui.js';

Expand Down Expand Up @@ -55,7 +56,7 @@ export class TokenAuthBackend implements Implementation {
// Authenticate against the delegate backend.
await this.delegate.authenticate(status);
// Let frontend know that user is logged in.
sessionStorage.setItem('decap-cms-logged-in', '1');
Cookies.set('decap-cms-logged-in', '1');
// Return status information.
return {
...status,
Expand All @@ -81,7 +82,7 @@ export class TokenAuthBackend implements Implementation {
async logout() {
await this.client.logout();
await this.delegate.logout();
sessionStorage.removeItem('decap-cms-logged-in');
Cookies.remove('decap-cms-logged-in');
}

/**
Expand Down
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1119b5a

Please sign in to comment.