From 0b4c55284d1eed731b7574250dd93e43cf42e3fc Mon Sep 17 00:00:00 2001 From: Project_IO Date: Wed, 11 Sep 2024 12:35:54 +0900 Subject: [PATCH] fix: auth router 500 issue fixed --- routes/auth.py | 6 ++++++ service/balance_service.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/routes/auth.py b/routes/auth.py index 0b5275f..de926a1 100644 --- a/routes/auth.py +++ b/routes/auth.py @@ -8,6 +8,12 @@ router = APIRouter() def login(auth: Credential, resp: Response): service = AuthService() data = service.read(auth.username) + if data == None: + resp.status_code = 401 + return { + "ok": 0, + "errno": "Unauthorized" + } hashed = hash(auth.password, data.salt) if data.username != auth.username or data.password != hashed: diff --git a/service/balance_service.py b/service/balance_service.py index 9ca9907..8a64be1 100644 --- a/service/balance_service.py +++ b/service/balance_service.py @@ -41,7 +41,7 @@ class BalanceService: def query(self): cur = self._conn.cursor() - cur.execute("select * from balset;") + cur.execute("select id, name, date, price, buy, memo from balset;") raw = cur.fetchall() data = [] @@ -63,7 +63,7 @@ class BalanceService: def read(self, id: int): cur = self._conn.cursor() - cur.execute("select * from balset where id = %s;", (id)) + cur.execute("select id, name, date, price, buy, memo from balset where id = %s;", (id)) data = cur.fetchone()