Allow superuser to not be verified #145
Draft
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.
Description
This PR aims to fix #144: when a custom flag field is used, and one tries to change the email of a superuser created by
createsuperuser
whose flag field is not enabled.The strategy employed is to disable user verification in
rest_registration.utils.users.get_user_by_lookup_dict
if the requested user is a superuser (i.e.is_superuser
is True). In other words, a superuser can be unverified.Two tests check if, when setting a custom flag field, the email address can be changed for an unverified superuser, and cannot be changed for an unverified normal user.
Improvements
Disabling user verification could be made optional. Either with an extra argument to the function (
required_verified_superuser
defaults to False), or with a settings (SUPERUSER_MUST_BE_VALIDATED
defaults to False).Why the change is needed?
See #144.
Related issues, pull requests, links
#144