mirror of
https://github.com/devproje/balance-application.git
synced 2024-10-20 15:11:21 +00:00
fix: auth router 500 issue fixed
This commit is contained in:
parent
ff65e414f7
commit
0b4c55284d
2 changed files with 8 additions and 2 deletions
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue