Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AUTH_USER_MODEL = 'app_name.MyUUIDModel'
- # REMOVE ALL PASSWORD Validators
- def create_user(self, uuid):
- user = self.model(
- uuid=self.normalize_email(email),
- )
- user.set_password(None)
- user.save(using=self._db)
- return user
- def create_superuser(self, uuid):
- user = self.create_user(uuid)
- user.save(using=self._db)
- return user
- def get_by_natural_key(self, email):
- return self.get(**{self.model.USERNAME_FIELD: email})
- class MyUUIDModel(AbstractBaseUser):
- uuid = models.CharField(max_length=36, unique=True)
- USERNAME_FIELD = 'uuid'
- objects = UUIDModelManager()
- def save(self, *args, **kwargs):
- super(MyUUIDModel, self).save(*args, **kwargs)
- AUTHENTICATION_BACKENDS = [
- 'django.contrib.auth.backends.ModelBackend',
- 'app_name.auth.MyAuth'
- ]
- class MyBackend(object):
- def authenticate(self, username=None, password=None):
- # Check if username i.e. UUID exists
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement