fix user not exist bug in frontend

This commit is contained in:
dni ⚡ 2022-12-23 11:53:45 +01:00
parent 1f75d5fd41
commit 1be460aec3
2 changed files with 13 additions and 10 deletions

View File

@ -38,7 +38,7 @@ async def favicon():
@core_html_routes.get("/", response_class=HTMLResponse)
async def home(request: Request, lightning: str = None):
async def home(request: Request, lightning: str = ""):
return template_renderer().TemplateResponse(
"core/index.html", {"request": request, "lnurl": lightning}
)
@ -124,12 +124,15 @@ async def wallet(
if (
len(settings.lnbits_allowed_users) > 0
and user_id not in settings.lnbits_allowed_users
and user_id not in settings.lnbits_admin_users
and user_id != settings.super_user
):
return template_renderer().TemplateResponse(
"error.html", {"request": request, "err": "User not authorized."}
)
if user_id == settings.super_user or user_id in settings.lnbits_admin_users:
user.admin = True
if not wallet_id:
if user.wallets and not wallet_name: # type: ignore
wallet = user.wallets[0] # type: ignore

View File

@ -233,15 +233,15 @@ async def check_user_exists(usr: UUID4) -> User:
status_code=HTTPStatus.NOT_FOUND, detail="User does not exist."
)
if len(settings.lnbits_allowed_users) > 0:
if (
g().user.id not in settings.lnbits_allowed_users
or g().user.id != settings.super_user
or g().user.id not in settings.lnbits_admin_users
):
raise HTTPException(
status_code=HTTPStatus.UNAUTHORIZED, detail="User not authorized."
)
if (
len(settings.lnbits_allowed_users) > 0
and g().user.id not in settings.lnbits_allowed_users
and g().user.id not in settings.lnbits_admin_users
and g().user.id != settings.super_user
):
raise HTTPException(
status_code=HTTPStatus.UNAUTHORIZED, detail="User not authorized."
)
return g().user