mirror of
https://github.com/jfmcbrayer/brutaldon
synced 2024-12-22 21:27:58 +01:00
Update userinfo on settings page
There are cases where your session['user'] dictionary can be out of date, like if you change your avatar. In that case, brutaldon will display a broken image instead of your avatar in various places. This change updates your settings info when you go to the settings page, in addition to as it normally does when you log in. Updating on every request would be possible, but it's another round trip to the instance, and I don't want the performance hit.
This commit is contained in:
parent
289bd28e28
commit
5c45a31cf1
@ -424,7 +424,10 @@ def user(request, username, prev=None, next=None):
|
||||
@never_cache
|
||||
@br_login_required
|
||||
def settings(request):
|
||||
account = Account.objects.get(username=request.session['username'])
|
||||
try:
|
||||
account, mastodon = get_usercontext(request)
|
||||
except NotLoggedInException:
|
||||
return redirect(about)
|
||||
if request.method == 'POST':
|
||||
form = PreferencesForm(request.POST)
|
||||
if form.is_valid():
|
||||
@ -440,6 +443,12 @@ def settings(request):
|
||||
request.session['timezone'] = account.preferences.timezone
|
||||
account.preferences.save()
|
||||
account.save()
|
||||
|
||||
# Update this here because it's a handy place to do it.
|
||||
user_info = mastodon.account_verify_credentials()
|
||||
request.session['user'] = user_info
|
||||
|
||||
|
||||
return redirect(home)
|
||||
else:
|
||||
return render(request, 'setup/settings.html',
|
||||
|
Loading…
Reference in New Issue
Block a user