2fa-login error: 'AnonymousUser' object has no attribute 'is_researcher'
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 12
- Forks
- 21
- Avg merge
- 5d 19h
- Merged PRs (30d)
- 5
Description
Summary
The 2fa-login page throws an error when the user enters the 2fa code after having the page open for a long time.
Description
On the 2fa-login page, if the session cookie (generated by the login page) expires before the user enters their 2fa (e.g. they leave the page open for a while), then entering their 2fa throws the error "'AnonymousUser' object has no attribute 'is_researcher'". This isn't a huge problem, but we should handle the exception and redirect the user to the login page in this case, especially since it happens pretty frequently and is clogging up our Sentry error quota (see error here).
Error happens here: https://github.com/lookit/lookit-api/blob/89e0467ae18014a2ac0bada52416ae14b759f991/accounts/views.py#L60-L62
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in accounts/views.py at lines 60-62, where the 2FA submission fails after the login session expires. Reproduce the flow by leaving the 2FA page open until the session cookie expires, then submit the code. Done means the expired-session case redirects to the login page instead of raising the AnonymousUser error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100