fix: Send create user email for password resets where we have an email and person, but no user.#7729
Conversation
|
I just noticed the various tests from https://github.com/ietf-tools/datatracker/blob/main/ietf/ietfauth/tests.py#L397 (which I somehow missed before — I'm definitely not an experienced python developer) I would've expected at least |
|
Thanks for the PR! Lots of questions above - we'll answer as best we can as the meeting allows. re: Mailpit (or any other thing) - when in development mode (what you'd be in while running Note that it's localhost from inside the container's perspective - you can map ports out to your host machine to get to services running there. If you're using the datatracker/docker/scripts/app-init.sh Line 104 in aa36f48 PersonFactory does indeed create a User. The new tests can say datatracker/ietf/person/factories.py Line 70 in aa36f48 Again - busy week with meeting - we'll look into the proposed solution and suggest good ways to test it soon. |
|
@rjsparks actually, I just tried |
|
ok - then after you have something like Other things may complain |
…l and person, but no user account This fixes ietf-tools#6458
62fafbe to
098c5a3
Compare
|
Okay, finally managed to get the tests fully working; I had to use EmailFactory instead of PersonFactory, but that still creates a Person so, I don't know why PersonFactory errored out continously. |
|
Unfortunately, I think we're going to need a different email round-trip sequence than reusing I walked through the rest of the process manually, and the result was very confusing (even if it mostly ended up with the right result). The mail that gets emitted looks like this: Which is disconnected from reality in this case - the "account" exists as far as the end user is concerned, so following the account exists instructions results in the wrong thing happening. Following the "if you don't have an account" path almost results in the right thing, but the user gets a form where they have to provide their name and ascii-name and a password. The provided name and ascii-name don't get used afaict. Also, we're got this @ThisIsMissEm - please feel free to continue to push if you have the energy, but if not, we can pick this up and finish it in a bit. We'll definitely use what you've provided so far. |
|
@rjsparks yeah, I totally agree that it's almost right but not quite — though, me being a new contributor + not really a python/django developer, I didn't think it'd be wise for me to setup a completely new flow, due to the security implications of that, hence reusing the existing flow to try to do a minimal "fix this so new comers who are on I-D's as co-authors don't get stuck" sense. |
|
The push above takes the solution in a slightly different direction, but I think it's the better path. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7729 +/- ##
==========================================
- Coverage 88.78% 88.77% -0.01%
==========================================
Files 296 296
Lines 41320 41350 +30
==========================================
+ Hits 36687 36710 +23
- Misses 4633 4640 +7 ☔ View full report in Codecov by Sentry. |
jennifer-richards
left a comment
There was a problem hiding this comment.
As much a question as a change request - see inline.
Though I think we should remove the comment about "The form validation checks that a matching User exists" because that part of the comment is outright false after the last round of refactoring. (The form no longer does anything beyond email syntax validation.)
I think this fixes: #6458
I've tested manually by deleting my own
auth_userdatabase entry (and associated entries inperson_historicalpersonandperson_historicalemail) to simulate a "missing user but known email and person" condition.I'm not sure how the codebase is tested, since I'm not usually a python developer, however
ietf/manage.py test --settings=settings_testseems to run fine. Though I do think it'd be good to have some sort of test coverage for exactly this case, since it seems like it's a pretty common issue for new editors/authors to encounter when collaborating with an existing IETF member on an I-D.Sure, we could use a different email template to be a bit more specific about onboarding, but the overall goal I think here is to get the person setup with an account, and the create account flow does exactly that.
Whilst working on this, I did notice that from within the docker container setup,
Site.objects.get_current().domaingivesdatatracker.ietf.orginstead oflocalhost:8000like I'd have expected, so in the logs the links appeared as:Instead of:
I also happen to have Mailpit running in my development environment, on port 2025, however the emails were just logged to the console; I assume this is just a standard development thing in python, but it could be neat to say "actually, yes, send all emails to this test email server"