add logic
This commit is contained in:
@@ -3,7 +3,7 @@ import type { AuthSession } from './auth.models';
|
||||
const SESSION_KEY = 'gorodar.session';
|
||||
|
||||
export function readAuthSession(): AuthSession | null {
|
||||
const raw = sessionStorage.getItem(SESSION_KEY);
|
||||
const raw = localStorage.getItem(SESSION_KEY);
|
||||
|
||||
if (!raw) {
|
||||
return null;
|
||||
@@ -13,7 +13,7 @@ export function readAuthSession(): AuthSession | null {
|
||||
const expired = !!session && typeof session.expiresAt === 'number' && session.expiresAt <= Date.now();
|
||||
|
||||
if (!session || !isEmail(session.email) || !session.accessToken || expired) {
|
||||
sessionStorage.removeItem(SESSION_KEY);
|
||||
localStorage.removeItem(SESSION_KEY);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ export function readAuthSession(): AuthSession | null {
|
||||
}
|
||||
|
||||
export function writeAuthSession(session: AuthSession): void {
|
||||
sessionStorage.setItem(SESSION_KEY, JSON.stringify(session));
|
||||
localStorage.setItem(SESSION_KEY, JSON.stringify(session));
|
||||
}
|
||||
|
||||
export function clearAuthSession(): void {
|
||||
sessionStorage.removeItem(SESSION_KEY);
|
||||
localStorage.removeItem(SESSION_KEY);
|
||||
}
|
||||
|
||||
function parseSession(raw: string): AuthSession | null {
|
||||
|
||||
Reference in New Issue
Block a user