Skip to content

Commit a540a3c

Browse files
committed
Storing social access tokens is now optional (closes pennersr#665)
1 parent 4ea7d91 commit a540a3c

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2014-08-08 Raymond Penners <raymond.penners@intenct.nl>
2+
3+
* Storing social access tokens is now optional
4+
(`SOCIALACCOUNT_STORE_TOKENS`).
5+
16
2014-07-26 Raymond Penners <raymond.penners@intenct.nl>
27

38
* Removed the inline Javascript from the `fbconnect.html`

allauth/socialaccount/app_settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def ADAPTER(self):
6363
def FORMS(self):
6464
return self._setting('FORMS', {})
6565

66+
@property
67+
def STORE_TOKENS(self):
68+
return self._setting('STORE_TOKENS', True)
69+
6670

6771
# Ugly? Guido recommends this himself ...
6872
# http://mail.python.org/pipermail/python-ideas/2012-May/014969.html

allauth/socialaccount/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from allauth.utils import (get_user_model, serialize_instance,
1919
deserialize_instance)
2020

21+
from . import app_settings
2122
from . import providers
2223
from .fields import JSONField
2324

@@ -220,7 +221,7 @@ def save(self, request, connect=False):
220221
user.save()
221222
self.account.user = user
222223
self.account.save()
223-
if self.token:
224+
if app_settings.STORE_TOKENS and self.token:
224225
self.token.account = self.account
225226
self.token.save()
226227
if connect:
@@ -249,7 +250,7 @@ def lookup(self):
249250
self.account = a
250251
a.save()
251252
# Update token
252-
if self.token:
253+
if app_settings.STORE_TOKENS and self.token:
253254
assert not self.token.pk
254255
try:
255256
t = SocialToken.objects.get(account=self.account,

docs/configuration.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,6 @@ SOCIALACCOUNT_FORMS (={})
146146

147147
SOCIALACCOUNT_PROVIDERS (= dict)
148148
Dictionary containing provider specific settings.
149+
150+
SOCIALACCOUNT_STORE_TOKENS (=True)
151+
Indicates whether or not the access tokens are stored in the database.

0 commit comments

Comments
 (0)