From: Matías Aguirre Date: Fri, 25 Feb 2011 13:32:42 +0000 (-0200) Subject: Save expiration time if not disabled by setting X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=ba45583526c1874a3eb23c740649559b79e6b938;p=django-social-auth.git Save expiration time if not disabled by setting --- diff --git a/README.rst b/README.rst index 9c6ff12..d224df6 100644 --- a/README.rst +++ b/README.rst @@ -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:: diff --git a/social_auth/views.py b/social_auth/views.py index 3b2ac9f..b83095c 100644 --- a/social_auth/views.py +++ b/social_auth/views.py @@ -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: