Skip to content

Commit

Permalink
Merge pull request #571 from curveball/fix-logout
Browse files Browse the repository at this point in the history
Fix logging out.
  • Loading branch information
evert authored Jan 21, 2025
2 parents 5bd0b45 + 37a88f2 commit 749e0fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/kv/redis-store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { createClient } from 'redis';
import { KvStore, SetOptions } from './abstract-store.js';
import dbg from 'debug';

const debug = dbg('redis-store');

type RedisConnection = ReturnType<typeof createClient>;

Expand All @@ -21,6 +24,7 @@ export class RedisKvStore extends KvStore {
*/
async get<T>(key: string): Promise<T | null> {

debug('Returning %s', key);
const val = await this.redis.get(key);
if (val===null) return null;
return JSON.parse(val);
Expand All @@ -32,6 +36,7 @@ export class RedisKvStore extends KvStore {
*/
async set(key: string, value: any, options?: SetOptions): Promise<void> {

debug('Storing %s', key);
if (options?.ttl) {
const newTtl = Math.floor(options.ttl / 1000);
await this.redis.setEx(
Expand All @@ -52,6 +57,7 @@ export class RedisKvStore extends KvStore {
*/
async delete(key: string): Promise<void> {

debug('Deleting: %s', key);
await this.redis.del(key);

}
Expand Down
2 changes: 1 addition & 1 deletion src/kv/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function getSessionStore(): SessionStore {
},

delete: (id: string): Promise<void> => {
return store.delete(id);
return store.delete('a12n:session:' + id);
},

newSessionId() {
Expand Down

0 comments on commit 749e0fa

Please sign in to comment.