Skip to content

Commit

Permalink
Merge pull request #6 from hurby24/patch-1
Browse files Browse the repository at this point in the history
fix(basic-api/redis): wrong delete key
  • Loading branch information
pilcrowonpaper authored Oct 18, 2024
2 parents 69dc2d5 + 11c3ed5 commit a32e9e2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pages/sessions/basic-api/redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export async function validateSessionToken(token: string): Promise<Session | nul
expiresAt: new Date(result.expires_at * 1000)
};
if (Date.now() >= session.expiresAt.getTime()) {
await redis.delete(sessionId);
await redis.delete(`session:${sessionId}`);
return null;
}
if (Date.now() >= session.expiresAt.getTime() - 1000 * 60 * 60 * 24 * 15) {
Expand Down Expand Up @@ -150,7 +150,7 @@ import { redis } from "./redis.js";
// ...

export async function invalidateSession(sessionId: string): Promise<void> {
await redis.delete(sessionId);
await redis.delete(`session:${sessionId}`);
}
```

Expand Down Expand Up @@ -202,7 +202,7 @@ export async function validateSessionToken(token: string): Promise<Session | nul
expiresAt: new Date(result.expires_at * 1000)
};
if (Date.now() >= session.expiresAt.getTime()) {
await redis.delete(sessionId);
await redis.delete(`session:${sessionId}`);
return null;
}
if (Date.now() >= session.expiresAt.getTime() - 1000 * 60 * 60 * 24 * 15) {
Expand All @@ -223,7 +223,7 @@ export async function validateSessionToken(token: string): Promise<Session | nul
}

export async function invalidateSession(sessionId: string): Promise<void> {
await redis.delete(sessionId);
await redis.delete(`session:${sessionId}`);
}

export interface Session {
Expand Down

0 comments on commit a32e9e2

Please sign in to comment.