diff --git a/files/routes/oauth.py b/files/routes/oauth.py index ae16109666..421b281c59 100644 --- a/files/routes/oauth.py +++ b/files/routes/oauth.py @@ -31,13 +31,8 @@ def authorize(v): return {"oauth_error": "Invalid `client_id`"}, 400 access_token = secrets.token_urlsafe(128)[:128] - try: - new_auth = ClientAuth(oauth_client = application.id, user_id = v.id, access_token=access_token) - g.db.add(new_auth) - except sqlalchemy.exc.IntegrityError: - g.db.rollback() - old_auth = g.db.query(ClientAuth).filter_by(oauth_client = application.id, user_id = v.id).one() - access_token = old_auth.access_token + new_auth = ClientAuth(oauth_client = application.id, user_id = v.id, access_token=access_token) + g.db.add(new_auth) return redirect(f"{application.redirect_uri}?token={access_token}")