return 404 when user cannot be found

This commit is contained in:
dsc 2022-03-13 09:56:21 +02:00
parent 9a51c3c4fb
commit 5af725f58d
1 changed files with 7 additions and 4 deletions

View File

@ -75,10 +75,13 @@ async def user_page(name: str):
if not name or len(name) <= 1:
raise Exception("invalid name")
_user = User.select().where(
User.username == name,
User.address.is_null(False)
).get()
try:
_user = User.select().where(
User.username == name,
User.address.is_null(False)
).get()
except:
return abort(404)
return await render_template('user.html', users=[_user])