forked from arti/doors
1
0
Fork 0

List user keycards on user info page

This commit is contained in:
Arti Zirk 2020-10-01 21:52:40 +03:00
parent de8af3cb0d
commit 472c762de2
2 changed files with 6 additions and 1 deletions

View File

@ -152,6 +152,10 @@ class DB:
""", keycards)
self.db.commit()
def get_user_keycards(self, user_id):
cur = self.db.execute("select id, name, created, disabled from keycards where user_id = ?", (user_id,))
return cur.fetchall()
@staticmethod
def import_ad(json_file):
with open(json_file) as fp:

View File

@ -128,7 +128,8 @@ def info(db, user_id):
user = db.get_user(user_id)
if not user:
raise HTTPError(404, "User does not exist")
return {**user, "keycards": []}
keycards = db.get_user_keycards(user_id)
return {**user, "keycards": keycards}
@app.route("/log")