Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow session stores to access information from the current request #1038

Open
luxaritas opened this issue Feb 1, 2022 · 1 comment
Open

Comments

@luxaritas
Copy link

I'm implementing a multi-tenant app where each tenant has its own database, and sessions should also be split between each database. I've written a custom session store, but as I am passing the tenant ID as a path parameter, the session store has no way to determine which database to use. For now, I have to basically re-implement sessions.

@luxaritas
Copy link
Author

luxaritas commented Feb 1, 2022

I actually found a different way around this than re-implementing sessions. What I did was when returning the token to the user on login, I formatted the token to include the tenant ID, and then in my session store's read method parsed it out. Then I also similarly serialized the user ID to include both the user ID and tenant ID, so that I could access it for save, update, and fetchUser operations. It's still a bit hacky and it would probably still be ideal to provide extra request-time data directly, but this is at least doable.

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

No branches or pull requests

1 participant