From 0dbfa5e0bc9729a603fe262ac3db0c6b3ad3b2f0 Mon Sep 17 00:00:00 2001 From: codl Date: Sat, 19 Aug 2017 14:32:31 +0200 Subject: [PATCH] fix 500 when logging in with mastdon with an existing oauth token --- lib/mastodon.py | 5 +++-- routes.py | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/mastodon.py b/lib/mastodon.py index 70f45ed..7101bc3 100644 --- a/lib/mastodon.py +++ b/lib/mastodon.py @@ -54,10 +54,11 @@ def receive_code(code, app, callback): remote_acc = api.account_verify_credentials() acc = account_from_api_object(remote_acc, app.instance) acc = db.session.merge(acc) - token = OAuthToken(account = acc, token = access_token) + token = OAuthToken(token = access_token) token = db.session.merge(token) + token.account = acc - return acc + return token def get_api_for_acc(account): diff --git a/routes.py b/routes.py index 221a978..91db87f 100644 --- a/routes.py +++ b/routes.py @@ -241,9 +241,8 @@ def mastodon_login_step2(instance): callback = url_for('mastodon_login_step2', instance=instance, _external=True) - account = lib.mastodon.receive_code(code, app, callback) - - account = db.session.merge(account) + token = lib.mastodon.receive_code(code, app, callback) + account = token.account sess = Session(account = account) db.session.add(sess)