Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/system/impl/native_python.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import secrets
from typing import Dict

import bcrypt
import psutil
from decouple import config
from fastapi import HTTPException, status
Expand Down Expand Up @@ -64,8 +64,8 @@ async def get_connection_info(self) -> ConnectionInfo:
return ConnectionInfo()

async def login(self, i: LoginInput) -> Dict[str, str]:
matches = secrets.compare_digest(i.password, config("login_password", cast=str))
if matches:
hashed_password = config("login_password", cast=str)
if bcrypt.checkpw(i.password.encode("utf-8"), hashed_password.encode("utf-8")):
return sign_jwt()

raise HTTPException(
Expand Down
4 changes: 3 additions & 1 deletion app/system/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ async def hw_info_sub(request: Request):
async def get_system_health(
verbose: bool = Query(
False,
description="Returns info about each subsytem running on this node if true. Currently not implemented.",
description="""Returns info about each
subsytem running on this node if
true. Currently not implemented.""",
),
) -> SystemHealthInfo:
return await system_health(verbose)
Expand Down
2 changes: 1 addition & 1 deletion tests/repositories/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def fake_match_pw_positive(_):
)

res = await sys.login(i=LoginInput(password="12345678"))
assert type(res) is dict
assert isinstance(res, dict)
assert res.startswith("ey") is True

async def fake_match_pw_negative(_):
Expand Down