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)