rcpch / rcpch-audit-engine

Epilepsy12 Audit Platform
https://e12.rcpch.ac.uk/
GNU Affero General Public License v3.0
5 stars 5 forks source link

Allow password reset even if user has never confirmed their email #1040

Closed eatyourpeas closed 1 month ago

eatyourpeas commented 2 months ago

Overview

A common situation is that users fail to click on their account creation link within 72 hours. What should happen: User contacts Epilepsy12 who navigate to the user in the platform -> edit user -> click on reset password This triggers a password reset email with a token to the user who clicks through to set a password This pathway has been retested and works. What actually happens: User does not contact Epilepsy12 team as directed as does not read the email. User navigates to password reset page and requests new password. Because the user does not yet have a useable password, no email is sent - this is django stock behaviour. There is no messaging to the user to say this, so frustration follows.

Proposed solution offered in this PR

Along with this small change in workflow, better signposting in the user table has been added, where a blue target appears next to the user if they have an active account (all accounts are active by default) but have yet to confirm their email. This is replaced by a pink tick if email has been confirmed. The popups have also been changed to clarify the users status.

Implications

Currently the email confirmation step is controlled by E12. This new work flow gives control for the email confirmation step to the user.

The alternative solution would be to retain the current work flow but institute better messaging in the emails and on the login and password reset screen directing users who have not yet confirmed their accounts to contact E12 and ask for the account confirmation email to be resent.

The only implications of this new proposed workflow are possibly that is a little less secure. In either situation, the only way an account could be created by a bad actor would be for them to intercept the emails or have access to the user's email account. The current workflow allows an E12 audit team member to have communication with the user wishing to confirm their account as an extra layer of security that they are happy the person is who they say they are. In the new work flow, a user that has access to an email address in the platform can reset the password and confirm the account in one step.

Code changes

The standard django ResetPasswordForm has been subclassed and the get_users method has been overridden to return all users with a matching email, so long as they are active, whether they have useable passwords or not. This class is used by the reset password view.

Some wording changes to the emails sent have been made, and to the create user form.

Related Issues

Closes #1039

mbarton commented 4 weeks ago

@SAbdin93 and I have confirmed on a teams call this works - the user was able to register and set 2fa