Bulk session wipe fix + logging
This commit is contained in:
parent
89bad2c5e5
commit
87a7b8b701
|
@ -23,6 +23,10 @@ function makeSessionID(userId: string, sessionId: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSessionsForUser(userId: string) {
|
export async function getSessionsForUser(userId: string) {
|
||||||
|
if (!userId) {
|
||||||
|
console.trace("Cannot get sessions for undefined userId")
|
||||||
|
return []
|
||||||
|
}
|
||||||
const client = await redis.getSessionClient()
|
const client = await redis.getSessionClient()
|
||||||
const sessions = await client.scan(userId)
|
const sessions = await client.scan(userId)
|
||||||
return sessions.map((session: Session) => session.value)
|
return sessions.map((session: Session) => session.value)
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
import * as sessions from "../sessions"
|
||||||
|
|
||||||
|
describe("sessions", () => {
|
||||||
|
describe("getSessionsForUser", () => {
|
||||||
|
it("returns empty when user is undefined", async () => {
|
||||||
|
// @ts-ignore - allow the undefined to be passed
|
||||||
|
const results = await sessions.getSessionsForUser(undefined)
|
||||||
|
|
||||||
|
expect(results).toStrictEqual([])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue