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

mongo: store the reset password tokens in a separate collection and use TTL to automatically delete them #935

Open
pradel opened this issue Apr 11, 2020 · 5 comments

Comments

@pradel
Copy link
Member

pradel commented Apr 11, 2020

Feature request

In the Mongo package, we could store the reset password tokens in a separate collection and use the TTL feature of Mongo to delete them automatically once they expire.
Right now if I ask a lot of reset password emails but actually never use them, the user object will never be cleaned and the service.password.reset object will be set to an array containing all the tokens. The tokens are only cleared if a user finish the process currently.

Additional context

This is a breaking change on the database schema.

Also, the same thing can be applied to:

  • verify email tokens
  • sessions
@sakulstra
Copy link
Contributor

I think that's a good idea 👍 and afaik also what meteor is doing for sessions?

@pradel
Copy link
Member Author

pradel commented Jul 7, 2020

@sakulstra iirc meteor is using an internal setInterval to delete the sessions

@sakulstra
Copy link
Contributor

You are right with "what meteor does" i meant cleaning up session, but not via TTL - not sure why though 🤔

@pradel
Copy link
Member Author

pradel commented Jul 7, 2020

@sakulstra the sessions are stored as a token saved inside the user object and TTL is not working in such case. If they wanted to use it they would have to move the sessions to a separate collection.
I remember reading an issue about this but they said that since it was not causing performance issues there was no point to move it to a separate collection.

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

2 participants