summaryrefslogtreecommitdiff
path: root/spoken_auth/managers.py
diff options
context:
space:
mode:
Diffstat (limited to 'spoken_auth/managers.py')
-rw-r--r--spoken_auth/managers.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/spoken_auth/managers.py b/spoken_auth/managers.py
new file mode 100644
index 0000000..953c867
--- /dev/null
+++ b/spoken_auth/managers.py
@@ -0,0 +1,27 @@
+import hashlib
+
+from django.db import models
+from django.contrib.auth.models import (
+ BaseUserManager, AbstractBaseUser
+)
+
+class DrupalUserManager(BaseUserManager):
+ def create_user(self, password=None):
+ user = self.model()
+ if not email:
+ raise ValueError('Users must have an email address')
+
+ user.set_password(password)
+ user.save(using=self._db)
+ return user
+
+ def create_superuser(self, username, password):
+ user = self.model()
+ user.id = 1
+ user.username= username
+ p = hashlib.md5()
+ p.update(password)
+ user.pass_field= p.hexdigest()
+ user.is_admin = True
+ user.save(using=self._db)
+ return user