From 0eaf76d8ee436d4cee5038171b9b2a14c5497115 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C3=ADas=20Aguirre?= Date: Wed, 22 Feb 2012 11:11:25 -0200 Subject: [PATCH] Inicial per backend settings, just URLs so far. --- README.rst | 18 ++++++++++++++++++ doc/configuration.rst | 17 +++++++++++++++++ social_auth/views.py | 7 +++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 543fbb6..46f567b 100644 --- a/README.rst +++ b/README.rst @@ -178,6 +178,11 @@ Configuration SOCIAL_AUTH_DISCONNECT_REDIRECT_URL = '/account-disconnected-redirect-url/' + Users will be redirected to ``LOGIN_ERROR_URL`` in case of error or user + cancellation on some backends. This URL can be override by this setting:: + + SOCIAL_AUTH_BACKEND_ERROR_URL = '/new-error-url/' + In case of authentication error, the message can be stored in session if the following setting is defined:: @@ -350,6 +355,19 @@ Configuration It's default value is ``DEBUG``, so you need to set it to ``False`` to avoid tracebacks when ``DEBUG = True``. + +Some settings can be tweak by backend by adding the backend name prefix (all +uppercase and replace ``-`` with ``_``), here's the supported settings so far:: + + LOGIN_ERROR_URL + SOCIAL_AUTH_BACKEND_ERROR_URL + SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL + SOCIAL_AUTH_DISCONNECT_REDIRECT_URL + SOCIAL_AUTH_NEW_USER_REDIRECT_URL + SOCIAL_AUTH_LOGIN_REDIRECT_URL + SOCIAL_AUTH_INACTIVE_USER_URL + + Authentication Pipeline ----------------------- diff --git a/doc/configuration.rst b/doc/configuration.rst index 01fcea7..73c3885 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -75,6 +75,11 @@ Configuration SOCIAL_AUTH_DISCONNECT_REDIRECT_URL = '/account-disconnected-redirect-url/' + Users will be redirected to ``LOGIN_ERROR_URL`` in case of error or user + cancellation on some backends. This URL can be override by this setting:: + + SOCIAL_AUTH_BACKEND_ERROR_URL = '/new-error-url/' + In case of authentication error, the message can be stored in session if the following setting is defined:: @@ -246,6 +251,18 @@ Configuration It's default value is ``DEBUG``, so you need to set it to ``False`` to avoid tracebacks when ``DEBUG = True``. +Some settings can be tweak by backend by adding the backend name prefix (all +uppercase and replace ``-`` with ``_``), here's the supported settings so far:: + + LOGIN_ERROR_URL + SOCIAL_AUTH_BACKEND_ERROR_URL + SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL + SOCIAL_AUTH_DISCONNECT_REDIRECT_URL + SOCIAL_AUTH_NEW_USER_REDIRECT_URL + SOCIAL_AUTH_LOGIN_REDIRECT_URL + SOCIAL_AUTH_INACTIVE_USER_URL + + .. _Model Manager: http://docs.djangoproject.com/en/dev/topics/db/managers/#managers .. _Login URL: http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#login-url .. _Login redirect URL: http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#login-redirect-url diff --git a/social_auth/views.py b/social_auth/views.py index b278dc8..ab8463a 100644 --- a/social_auth/views.py +++ b/social_auth/views.py @@ -173,11 +173,14 @@ def complete_process(request, backend, *args, **kwargs): # Remove possible redirect URL from session, if this is a new # account, send him to the new-users-page if defined. - new_user_redirect = setting('SOCIAL_AUTH_NEW_USER_REDIRECT_URL') + new_user_redirect = backend_setting(backend, + 'SOCIAL_AUTH_NEW_USER_REDIRECT_URL') if new_user_redirect and getattr(user, 'is_new', False): url = new_user_redirect else: - url = redirect_value or DEFAULT_REDIRECT + url = redirect_value or \ + backend_setting('SOCIAL_AUTH_LOGIN_REDIRECT_URL') or \ + DEFAULT_REDIRECT else: url = backend_setting(backend, 'SOCIAL_AUTH_INACTIVE_USER_URL', LOGIN_ERROR_URL) -- 2.39.5