diff --git a/src/autotrain/__init__.py b/src/autotrain/__init__.py index 9aa6b57255..9f4867dd5d 100644 --- a/src/autotrain/__init__.py +++ b/src/autotrain/__init__.py @@ -41,4 +41,4 @@ logger = Logger().get_logger() -__version__ = "0.7.58.dev0" +__version__ = "0.7.59.dev0" diff --git a/src/autotrain/app.py b/src/autotrain/app.py index cd8f45e5f5..77b056d1a9 100644 --- a/src/autotrain/app.py +++ b/src/autotrain/app.py @@ -2,6 +2,7 @@ import os from typing import List +import requests import torch from fastapi import FastAPI, File, Form, HTTPException, Query, Request, UploadFile from fastapi.responses import HTMLResponse, JSONResponse, RedirectResponse @@ -173,8 +174,12 @@ async def load_index(request: Request): token = request.session["oauth_info"]["access_token"] else: token = HF_TOKEN - - _users = app_utils.user_validation(user_token=token) + try: + _users = app_utils.user_validation(user_token=token) + except requests.exceptions.JSONDecodeError: + if "oauth_info" in request.session: + request.session.pop("oauth_info", None) + return templates.TemplateResponse("login.html", {"request": request}) context = { "request": request, "valid_users": _users,