Support custom verification status based on email #504
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this change do?
This pull request extends the interface of
LoginSerializer.validate_email_verification_status
to pass-through the email value that's used for the current login. This interface change enables us to customize the logic to check the verification status in subclasses without needing to override the fullvalidate
method, thus reducing coupling between subclasses and the parent.Why is this useful?
I'm working on a system where the user is allowed to change their email but they need to verify their new email before they can use it to log in. Currently, dj-rest-auth will allow the user to log in with their new email address even before it's verified as the code is checking that the user has any verified email address. I want to customize this behavior by subclassing to check that the specific email address the user is logging in with is verified:
Arguably dj-rest-auth could even make this check the default behavior as it seems semantically correct, but this would be a backwards incompatible change which is why I propose the change in this PR to simply extend the interface of the validation function.