]> git.parisson.com Git - django-social-auth.git/commitdiff
Use Django's md5_constructor for backwards compatibility.
authorJannis Leidel <jannis@leidel.info>
Wed, 5 Jan 2011 16:40:55 +0000 (17:40 +0100)
committerJannis Leidel <jannis@leidel.info>
Wed, 5 Jan 2011 16:40:55 +0000 (17:40 +0100)
social_auth/backends.py

index 374ffe37715408078433e76d715c1d4b30a8b36a..362eea35da58cbb85466a49045409eccc816e2fd 100644 (file)
@@ -2,12 +2,12 @@
 Authentication backeds for django.contrib.auth AUTHENTICATION_BACKENDS setting
 """
 from os import urandom
-from hashlib import md5
 
 from openid.extensions import ax, sreg
 
 from django.conf import settings
 from django.contrib.auth.backends import ModelBackend
+from django.utils.hashlib import md5_constructor
 
 from .models import UserSocialAuth
 from .conf import OLD_AX_ATTRS, AX_SCHEMA_ATTRS
@@ -67,7 +67,7 @@ class SocialAuthBackend(ModelBackend):
         """
         def get_random_username():
             """Return hash from random string cut at 30 chars"""
-            return md5(str(urandom(10))).hexdigest()[:30]
+            return md5_constructor(str(urandom(10))).hexdigest()[:30]
 
         if getattr(settings, 'SOCIAL_AUTH_FORCE_RANDOM_USERNAME', False):
             username = get_random_username()