Quick fix for a security issue with login form

This commit is contained in:
Jason McBrayer 2018-04-30 20:32:50 -04:00
parent 421d27ef07
commit 8d6ebfc0b2

View File

@ -96,14 +96,19 @@ def login(request):
except (Account.DoesNotExist, Account.MultipleObjectsReturned): except (Account.DoesNotExist, Account.MultipleObjectsReturned):
account = Account( account = Account(
username = username, username = username,
access_token = access_token, access_token = "",
client = client) client = client)
try:
access_token = mastodon.log_in(username, access_token = mastodon.log_in(username,
password) password)
account.access_token = access_token
account.save() account.save()
request.session['username'] = username request.session['username'] = username
return redirect(home) return redirect(home)
except:
# FIXME: add the errors
return render(request, 'setup/login.html', {'form': form})
else: else:
return render(request, 'setup/login.html', {'form': form}) return render(request, 'setup/login.html', {'form': form})