How do I modify djoser account verification system
Here's my custom user model:
class Account(AbstractBaseUser):
email = models.EmailField(unique=True, max_length=255)
firstname = models.CharField(max_length=40)
lastname = models.CharField(max_length=40)
date_joined = models.DateTimeField(auto_now_add=True)
is_active = models.BooleanField(default=True)
is_verif = models.BooleanField(default=)
is_superuser = models.BooleanField(default=False)
USERNAME_FIELD = "email"
REQUIRED_FIELDS = ["firstname", "lastname"]
objects = AccountManager()
def __str__(self):
return self.email
@property
def is_staff(self):
return self.is_superuser
@property
def is_admin(self):
return self.is_superuser
def has_perm(*args, **kwargs):
return True
def has_module_perms(*args, **kwargs):
return True
So right now I have a standard djoser account verification system. So I'm unable to login with unverified user because the is_active
field is set to False
.
Where and how do I modify the code so that every time I verify an account it checks the is_verif
field instead of the is_active
and the is_active
field is always set to True ?
Thank you
You can replace the is_active field with a methods named is_active with the @property decorator and inside that method return the is_verif value.
@property
def is_active(self):
return self.is_verif
But this solution works only if you don't need the is_active field.