Wrap PasswordResetTokenGenerator in TokenGenerator instead of subclassing it
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
TokenGenerator subclasses Django's PasswordResetTokenGenerator, but every caller passes it a user id, not a User. Only the _make_hash_value override names the parameter user_id. make_token and check_token still call it user, matching the inherited User-typed signatures, which has misled reviewers about what the methods accept. TokenGenerator should wrap PasswordResetTokenGenerator instead of subclassing it, so its interface takes a user id explicitly.
Complexity: Low Target branch: develop
Context
TokenGeneratorfully overridesmake_tokenandcheck_token. From the base class it only uses_make_token_with_timestamp(the salted HMAC) and thesecret/algorithm/key_saltset up in__init__.- Django's
_make_token_with_timestamp(user, timestamp)passesuserstraight to_make_hash_value, which Kolibri overrides to returnf"{user_id}{timestamp}". - Callers:
kolibri/core/auth/viewsets/session.py,kolibri/core/device/tasks.py,kolibri/plugins/user_profile/tasks.py,kolibri/plugins/user_profile/viewsets/user_profile.py.
The Change
TokenGeneratorshould expose onlymake_token(user_id)andcheck_token(user_id, token).- Token behaviour should stay the same: HMAC-signed with the Django secret, valid for
TOKEN_EXPIRE_LIMITseconds.
Acceptance Criteria
- [ ]
TokenGeneratordoes not subclassPasswordResetTokenGenerator. - [ ]
make_tokenandcheck_tokenname their first parameteruser_id. - [ ] The existing tests in
kolibri/core/utils/test/test_token_generator.pyandkolibri/plugins/user_profile/test/test_api.pypass unchanged.
References
AI usage
I chose the scope (wrap rather than rename) and the criteria. Claude Code read the Django base class and callers and drafted the sections.
Hello team,
I noticed that this issue has not yet been opened for contribution or assigned to any contributor. I am very interested in working on it as my first contribution to Kolibri.
I would be grateful if you could consider allowing me to work on this issue and assign it to me. I am eager to contribute and learn from the process.
Thank you!
Hi! 👋
Thanks so much for your interest! This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues. If there are no unassigned 'help wanted' issues available, please wait until new ones are added.
We really appreciate your willingness to help. 😊
Are you preparing for Google Summer of Code? See our GSoC guidelines.