Repo refactor and webproject hooks fixes
[astakos] / astakos / im / auth_backends.py
diff --git a/astakos/im/auth_backends.py b/astakos/im/auth_backends.py
deleted file mode 100644 (file)
index bae0532..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-from django.contrib.auth.backends import ModelBackend
-from django.core.validators import email_re
-
-from astakos.im.models import AstakosUser
-
-class TokenBackend(ModelBackend):
-    """
-    AuthenticationBackend used to authenticate using token instead
-    """
-    def authenticate(self, email=None, auth_token=None):
-        try:
-            user = AstakosUser.objects.get(email=email)
-            if user.auth_token == auth_token:
-                return user
-        except AstakosUser.DoesNotExist:
-            return None
-
-    def get_user(self, user_id):
-        try:
-            return AstakosUser.objects.get(pk=user_id)
-        except AstakosUser.DoesNotExist:
-            return None
-
-class EmailBackend(ModelBackend):
-    """
-    If the ``username`` parameter is actually an email uses email to authenticate
-    the user else tries the username.
-    
-    Used from ``astakos.im.forms.LoginForm`` to authenticate.
-    """
-    def authenticate(self, username=None, password=None):
-        #If username is an email address, then try to pull it up
-        if email_re.search(username):
-            try:
-                user = AstakosUser.objects.get(email=username)
-            except AstakosUser.DoesNotExist:
-                return None
-        else:
-            #We have a non-email address username we
-            #should try username
-            try:
-                user = AstakosUser.objects.get(username=username)
-            except AstakosUser.DoesNotExist:
-                return None
-        if user.check_password(password):
-            return user
-    
-    def get_user(self, user_id):
-        try:
-            return AstakosUser.objects.get(pk=user_id)
-        except AstakosUser.DoesNotExist:
-            return None
\ No newline at end of file