fix for user registration
This commit is contained in:
@@ -2,9 +2,11 @@ from django.db import models
|
||||
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
|
||||
from django.contrib.auth.models import PermissionsMixin
|
||||
|
||||
from companies.models import Company
|
||||
|
||||
|
||||
# Create your models here.
|
||||
class UserManager(BaseUserManager):
|
||||
class CustomUserManager(BaseUserManager):
|
||||
use_in_migrations = True
|
||||
|
||||
def _create_user(self, email, password, **extra_fields):
|
||||
@@ -16,7 +18,7 @@ class UserManager(BaseUserManager):
|
||||
email = self.normalize_email(email)
|
||||
user = self.model(email=email, **extra_fields)
|
||||
user.set_password(password)
|
||||
user.save(using=self._db)
|
||||
user.save()
|
||||
return user
|
||||
|
||||
def create_user(self, email, password=None, **extra_fields):
|
||||
@@ -42,7 +44,7 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
|
||||
notify = models.BooleanField('Notificar', default=False, null=True)
|
||||
provider = models.CharField('Proveedor', max_length=1000, blank=True, null=True) # red social de registro
|
||||
email_verified = models.BooleanField('Email verificado', default=False, null=True)
|
||||
company = None # models.ForeignKey(Empresa, null=True, on_delete=models.DO_NOTHING)
|
||||
company = models.ForeignKey(Company, null=True, on_delete=models.DO_NOTHING, related_name='custom_user')
|
||||
|
||||
is_active = models.BooleanField('Activo', default=True)
|
||||
is_staff = models.BooleanField('Empleado',default=False )
|
||||
@@ -51,7 +53,7 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
|
||||
created = models.DateTimeField(auto_now_add=True, null=True, blank=True)
|
||||
last_visit = models.DateTimeField(auto_now=True)
|
||||
|
||||
objects = UserManager()
|
||||
objects = CustomUserManager()
|
||||
|
||||
USERNAME_FIELD = 'email'
|
||||
REQUIRED_FIELDS = []
|
||||
|
||||
Reference in New Issue
Block a user