]> git.parisson.com Git - django-social-auth.git/commitdiff
Doc fix and added missing check
authorMatías Aguirre <matiasaguirre@gmail.com>
Tue, 23 Nov 2010 05:45:58 +0000 (03:45 -0200)
committerMatías Aguirre <matiasaguirre@gmail.com>
Tue, 23 Nov 2010 05:45:58 +0000 (03:45 -0200)
README.rst
social_auth/models.py

index ed364daf986fc5a61ef9548d9a8f0159e3469604..d03e32042b436c09cee545bd1719bd41039deb6f 100644 (file)
@@ -108,7 +108,7 @@ and the methods::
     is_authenticated()
 
 AttributeError will be raised in case of any of these is
-missing, also the following are recommended but notenforced::
+missing, also the following are recommended but not enforced::
 
     first_name = CharField(...)
     last_name  = CharField(...)
index 325f6ddadbea118c96059c35147e83b65baa0d37..c09137aaf3ef037e813db31bf2c10c1ebbd786b0 100644 (file)
@@ -3,15 +3,26 @@ from django.db import models
 from django.conf import settings
 
 # If User class is overrided, it must provide the following fields:
+#
 #   username = CharField()
 #   email = EmailField()
 #   password = CharField()
+#   is_active  = BooleanField()
+#
+# and methods:
+#
+#   def is_authenticated():
+#       ...
 MANDATORY_FIELDS = ('username', 'email', 'password', 'last_login')
+MANDATORY_METHODS = ('is_authenticated',)
 
 try: # try to import User model override and validate needed fields
     User = models.get_model(*settings.SOCIAL_AUTH_USER_MODEL.split('.'))
     if not all(User._meta.get_field(name) for name in MANDATORY_FIELDS):
         raise AttributeError, 'Some mandatory field missing'
+    if not all(callable(getattr(User, name, None))
+                    for name in MANDATORY_METHODS):
+        raise AttributeError, 'Some mandatory methods missing'
 except: # fail silently and fallback to auth.User on any error
     from django.contrib.auth.models import User