Skip to content

Commit

Permalink
feat: creating a user without an email raises a ValueError
Browse files Browse the repository at this point in the history
  • Loading branch information
nkordis committed May 1, 2024
1 parent 6b96bde commit 1b8d9fd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class UserManager(BaseUserManager):

def create_user(self, email, password=None, **extra_fields):
"""Create, save and return a new user."""
if not email:
raise ValueError('User must have an email address')
user = self.model(email=self.normalize_email(email), **extra_fields)
user.set_password(password)
user.save(using=self._db)
Expand Down

0 comments on commit 1b8d9fd

Please sign in to comment.