From e7434f5c7d1db144805f46944d2ccc1da24f0c5b Mon Sep 17 00:00:00 2001 From: Jonatan Heyman Date: Mon, 13 Aug 2012 13:08:34 +0200 Subject: [PATCH] Fixed issue that could cause a race condition when (re-)saving facebook access tokens --- socialregistration/contrib/facebook/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/socialregistration/contrib/facebook/models.py b/socialregistration/contrib/facebook/models.py index a66fbc7..b8c4e9b 100644 --- a/socialregistration/contrib/facebook/models.py +++ b/socialregistration/contrib/facebook/models.py @@ -26,12 +26,12 @@ class FacebookAccessToken(models.Model): def save_facebook_token(sender, user, profile, client, **kwargs): try: - FacebookAccessToken.objects.get(profile=profile).delete() + access_token = FacebookAccessToken.objects.get(profile=profile) except FacebookAccessToken.DoesNotExist: - pass + access_token = FacebookAccessToken(profile=profile) - FacebookAccessToken.objects.create(profile=profile, - access_token=client.graph.access_token) + access_token.access_token = client.graph.access_token + access_token.save() connect.connect(save_facebook_token, sender=FacebookProfile, dispatch_uid='socialregistration.facebook.connect')