Fix crash in oauth_callback
This commit is contained in:
parent
10d1194250
commit
2fd5ef86b3
|
@ -200,14 +200,18 @@ def oauth_callback(request):
|
||||||
try:
|
try:
|
||||||
account = Account.objects.get(username=user.username)
|
account = Account.objects.get(username=user.username)
|
||||||
account.access_token = access_token
|
account.access_token = access_token
|
||||||
|
if not account.preferences:
|
||||||
|
preferences = Preference(theme = Theme.objects.get(id=1))
|
||||||
|
preferences.save()
|
||||||
|
account.preferences = preferences
|
||||||
account.save()
|
account.save()
|
||||||
except (Account.DoesNotExist, Account.MultipleObjectsReturned):
|
except (Account.DoesNotExist, Account.MultipleObjectsReturned):
|
||||||
preferences = Preference(theme = Theme.objects.get(id=1))
|
preferences = Preference(theme = Theme.objects.get(id=1))
|
||||||
|
preferences.save()
|
||||||
account = Account(username=user.acct,
|
account = Account(username=user.acct,
|
||||||
access_token = access_token,
|
access_token = access_token,
|
||||||
client = Client.objects.get(api_base_id=request.session['instance']),
|
client = Client.objects.get(api_base_id=request.session['instance']),
|
||||||
preferences = preferences)
|
preferences = preferences)
|
||||||
preferences.save()
|
|
||||||
request.session['user'] = user
|
request.session['user'] = user
|
||||||
request.session['username'] = user.username
|
request.session['username'] = user.username
|
||||||
account.username = user.username
|
account.username = user.username
|
||||||
|
|
Loading…
Reference in New Issue