Skip to content

Session ID cleanup on delete #10

Description

@yayza

Since createSession always adds the session ID to the user set in redis, shouldn't it also always remove it in deleteSession? At the moment deleteSession userId is initialized to null, so this part never gets checked unless I explicitily add the user's ID (had to look at the lib code to figure out why I had so many sessions even when using deleteSession/deleteCookie but they would clean up if I used deleteSessionByUserId):

if (userId) {
	const redisPipeline = this.redisClient.pipeline();
	redisPipeline.del(prefixedSessionKey);
	redisPipeline.srem(getUserSessionKey(this.userSessionsPrefix, userId), sessionId);
	await redisPipeline.exec();
} else {
	await this.redisClient.del(prefixedSessionKey);
}

Maybe i'm overlooking another reason for checking for userId

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions