]> git.parisson.com Git - django-social-auth.git/commitdiff
Save expiration time if not disabled by setting
authorMatías Aguirre <matiasaguirre@gmail.com>
Fri, 25 Feb 2011 13:32:42 +0000 (11:32 -0200)
committerMatías Aguirre <matiasaguirre@gmail.com>
Fri, 25 Feb 2011 13:32:42 +0000 (11:32 -0200)
README.rst
social_auth/views.py

index 9c6ff126c5dc3177db806fc8480fa01e5908aca4..d224df63c699283fd4528de700878c396957fe99 100644 (file)
@@ -203,8 +203,11 @@ Configuration
     SOCIAL_AUTH_EXPIRATION = 'expires'
 
   to and use such setting name where expiration times are returned. View that
-  completes login process will set session expiration time to this value if
-  it's present.
+  completes login process will set session expiration time using this name if
+  it's present or 'expires' by default. Expiration time saving can be disabled
+  setting::
+
+    SOCIAL_AUTH_SESSION_EXPIRATION = False
 
 - It's possible to override the used User model if needed::
 
index 3b2ac9fe631511095f8891972e765ecfabf4d8d9..b83095cf57944cba9d87957c94f9a3542101290d 100644 (file)
@@ -41,10 +41,12 @@ def complete_process(request, backend):
 
     if user and getattr(user, 'is_active', True):
         login(request, user)
-        # set session expiration date if present
-        social_user = user.social_auth.get(provider=backend.AUTH_BACKEND.name)
-        if social_user.expiration_delta():
-            request.session.set_expiry(social_user.expiration_delta())
+        if getattr(settings, 'SOCIAL_AUTH_SESSION_EXPIRATION', True):
+            # Set session expiration date if present and not disabled by setting
+            backend_name = backend.AUTH_BACKEND.name
+            social_user = user.social_auth.get(provider=backend_name)
+            if social_user.expiration_delta():
+                request.session.set_expiry(social_user.expiration_delta())
         url = request.session.pop(REDIRECT_FIELD_NAME, '') or \
               getattr(settings, 'LOGIN_REDIRECT_URL', '')
     else: