Hi sorry for being unclear...
I currently have this standard user model:

from django.db import models
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager


class MyAccountManager(BaseUserManager):
   def create_user(self, email, username, first_name, last_name, password=None):
      if not email:
         raise ValueError('Users must have an email address')
      # if not username:
      #  raise ValueError('Users must have a username')
      if not first_name:
         raise ValueError('Users must have a first name')
      if not last_name:
         raise ValueError('Users must have a last name')

      user = self.model(
         email=self.normalize_email(email),
         # username=username,
         first_name=first_name,
         last_name=last_name
      )

      user.set_password(password)
      user.save(using=self._db)
      return user

   def create_superuser(self, email, password):
      user = self.create_user(
         email=self.normalize_email(email),
         password=password,
         # username=username,
      )
      user.is_admin = True
      user.is_staff = True
      user.is_superuser = True
      user.save(using=self._db)
      return user


class Account(AbstractBaseUser):
   email              = models.EmailField(verbose_name="email",
max_length=60, unique=True)
   # username              = models.CharField(max_length=30, unique=True)
   # TODO: for production do not allow null field
   first_name          = models.CharField(verbose_name="first_name",
max_length=40)
   last_name           = models.CharField(verbose_name="last_name",
max_length=40)
   date_joined             = models.DateTimeField(verbose_name='date
joined', auto_now_add=True)
   last_login          = models.DateTimeField(verbose_name='last
login', auto_now=True)
   is_admin            = models.BooleanField(default=False)
   is_active           = models.BooleanField(default=True)
   is_staff            = models.BooleanField(default=False)
   is_superuser         = models.BooleanField(default=False)


   USERNAME_FIELD = 'email'
   REQUIRED_FIELDS = ['first_name','last_name']

   objects = MyAccountManager()

   def __str__(self):
      return self.email

   # For checking permissions. to keep it simple all admin have ALL permissons
   def has_perm(self, perm, obj=None):
      return self.is_admin

   # Does this user have permission to view this app? (ALWAYS YES FOR
SIMPLICITY)
   def has_module_perms(self, app_label):
      return True

And know I would like to implement an email verification step that sets the
user to active when verified using allauth django package.
But I do not know how to do it...

Best wishes,

Manuel



Manuel Buri
T:  +41 79 933 01 11
M: [email protected]
W: www.manuelburi.com <http://manuelburi.com/?utm_source=gmail>


On Tue, 9 Mar 2021 at 17:24, Gabriel Araya Garcia <
[email protected]> wrote:

> Your ask is not clear,..What is wrong ? What is the error message? If
> you need validate the email format, here is one javascript example :
>
> function validaemail(email) {
> if(email=="correo"){
>     var x = document.getElementById("correo").value
> } else {
>     var x = document.getElementById("correo_apod").value
> }
>
>     if(x!='') {
>         var expr =
> /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
>         if ( !expr.test(x) ) {
>             alert("Error: La dirección de correo " + x + " es
> incorrecta.");
>             document.getElementById("correo").value = "";
>         }
>     }
> }
>
> Regards,
>
> Gabriel Araya Garcia
> GMI - Desarrollo de Sistemas Informáticos
> Santiago of Chile
>
>
>
>
> El mar, 9 mar 2021 a las 11:47, Manuel Buri (<[email protected]>)
> escribió:
>
>> Hi, I am a bit lost while trying to add user email verification step to
>> my custom user model that is based on AbstractBaseUser. Did someone do that
>> already or if not how should I do it differently?
>> Thank you so much!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/aeec0130-5ef5-48f6-bb37-61d8ebeafd6fn%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/aeec0130-5ef5-48f6-bb37-61d8ebeafd6fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/YveSLX-SJRg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAKVvSDASwaPPf%3DK4kW7bDAV9yVke7Xh8E_Hr_3_A75gJYjSPnQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAKVvSDASwaPPf%3DK4kW7bDAV9yVke7Xh8E_Hr_3_A75gJYjSPnQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACx7KORpbArBz%2BTEo-vJxRwEJ7OQ1n9yjKaE8UUNbLhC2N-NbQ%40mail.gmail.com.

Reply via email to