Advertisement
Guest User

Untitled

a guest
Apr 12th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. AUTH_USER_MODEL = 'app_name.MyUUIDModel'
  2. # REMOVE ALL PASSWORD Validators
  3.  
  4. def create_user(self, uuid):
  5. user = self.model(
  6. uuid=self.normalize_email(email),
  7. )
  8. user.set_password(None)
  9. user.save(using=self._db)
  10. return user
  11.  
  12. def create_superuser(self, uuid):
  13. user = self.create_user(uuid)
  14. user.save(using=self._db)
  15. return user
  16.  
  17. def get_by_natural_key(self, email):
  18. return self.get(**{self.model.USERNAME_FIELD: email})
  19.  
  20. class MyUUIDModel(AbstractBaseUser):
  21. uuid = models.CharField(max_length=36, unique=True)
  22. USERNAME_FIELD = 'uuid'
  23. objects = UUIDModelManager()
  24. def save(self, *args, **kwargs):
  25. super(MyUUIDModel, self).save(*args, **kwargs)
  26.  
  27. AUTHENTICATION_BACKENDS = [
  28. 'django.contrib.auth.backends.ModelBackend',
  29. 'app_name.auth.MyAuth'
  30. ]
  31.  
  32. class MyBackend(object):
  33. def authenticate(self, username=None, password=None):
  34.  
  35. # Check if username i.e. UUID exists
  36. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement