Skip to content

Commit

Permalink
fix login error
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekkrthakur committed Apr 23, 2024
1 parent 2961150 commit a790c9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/autotrain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@


logger = Logger().get_logger()
__version__ = "0.7.58.dev0"
__version__ = "0.7.59.dev0"
9 changes: 7 additions & 2 deletions src/autotrain/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a790c9a

Please sign in to comment.