fix: auth router 500 issue fixed

This commit is contained in:
Project_IO 2024-09-11 12:35:54 +09:00
parent ff65e414f7
commit 0b4c55284d
2 changed files with 8 additions and 2 deletions

View file

@ -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:

View file

@ -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()