From 97579bda71036786ae41134d2b2033bd0f1ac88b Mon Sep 17 00:00:00 2001 From: eric Date: Thu, 9 Apr 2015 12:41:00 -0400 Subject: [PATCH] re-establish un length limit --- core/auth.py | 7 ++++--- settings/common.py | 18 +++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/core/auth.py b/core/auth.py index 60b649e3..23393355 100644 --- a/core/auth.py +++ b/core/auth.py @@ -14,7 +14,6 @@ logger = logging.getLogger(__name__) def selectively_associate(backend, uid, user=None, *args, **kwargs): """Not using Facebook or Twitter to authenticate a user. """ - logger.info('selectively_associate') social_auth = UserSocialAuth.get_social_auth(backend.name, uid) if backend.name in ('twitter', 'facebook'): # not for authentication @@ -50,7 +49,6 @@ def twitter_extra_values( user, extra_data): def deliver_extra_data(backend, details, response, uid, user, social_user=None, *args, **kwargs): - logger.info('deliver_extra_data') pipeline_data = load_extra_data(backend, details, response, uid, user, social_user=None, *args, **kwargs) @@ -58,4 +56,7 @@ def deliver_extra_data(backend, details, response, uid, user, social_user=None, twitter_extra_values( user, social_user.extra_data) if backend.name is 'facebook': facebook_extra_values( user, social_user.extra_data) - + +# following is needed because of length limitations in a unique constrain for MySQLdef chop_username(username, *args, **kwargs): + if username and len(username)>222: + return {'username':username[0:222]} diff --git a/settings/common.py b/settings/common.py index 24056713..8b504d32 100644 --- a/settings/common.py +++ b/settings/common.py @@ -218,9 +218,6 @@ SOCIAL_AUTH_ENABLED_BACKENDS = ['google', 'facebook', 'twitter'] SOCIAL_AUTH_NEW_USER_REDIRECT_URL = '/' FACEBOOK_SOCIAL_AUTH_BACKEND_ERROR_URL = '/' SOCIAL_AUTH_SLUGIFY_USERNAMES = True -# following is needed because of length limitations in a unique constrain for MySQL -# see https://github.com/omab/django-social-auth/issues/539 -# SOCIAL_AUTH_UID_LENGTH = 222 deprecated in PSA SOCIAL_AUTH_NONCE_SERVER_URL_LENGTH = 200 SOCIAL_AUTH_ASSOCIATION_SERVER_URL_LENGTH = 135 SOCIAL_AUTH_ASSOCIATION_HANDLE_LENGTH = 125 @@ -247,12 +244,17 @@ SOCIAL_AUTH_PIPELINE = ( # Make up a username for this person, appends a random string at the end if # there's any collision. 'social.pipeline.user.get_username', - + + # make username < 222 in length + 'regluit.core.auth.chop_username', + # Send a validation email to the user to verify its email address. # Disabled by default. # 'social.pipeline.mail.mail_validation', - + + # don't use twitter or facebook to log in 'regluit.core.auth.selectively_associate', + # Associates the current social details with another user account with # a similar email address. Disabled by default. 'social.pipeline.social_auth.associate_by_email', @@ -262,12 +264,14 @@ SOCIAL_AUTH_PIPELINE = ( # Create the record that associated the social account with this user. 'social.pipeline.social_auth.associate_user', - 'regluit.core.auth.deliver_extra_data', - + # Populate the extra_data field in the social record with the values # specified by settings (and the default ones like access_token, etc). 'social.pipeline.social_auth.load_extra_data', + # add extra data to user profile + 'regluit.core.auth.deliver_extra_data', + # Update the user record with any changed info from the auth service. 'social.pipeline.user.user_details' )