mirror of
https://github.com/fusion44/blitz_api.git
synced 2026-08-16 12:20:14 +02:00
password & migration implementation
This commit is contained in:
parent
6ceaacfc23
commit
25ec9f0af5
2 changed files with 35 additions and 2 deletions
|
|
@ -79,6 +79,7 @@ def write_text_file(filename: str, arrayOfLines):
|
|||
@router.post("/setup-start-done")
|
||||
async def setup_start_done(
|
||||
hostname : str = "",
|
||||
forceFreshSetup : bool = FALSE,
|
||||
keepBlockchain : bool = FALSE,
|
||||
lightning : str = "",
|
||||
passwordA : str = "",
|
||||
|
|
@ -95,6 +96,11 @@ async def setup_start_done(
|
|||
logging.warning(f"/setup-start-done can only be called when nodes awaits setup")
|
||||
return HTTPException(status.HTTP_405_METHOD_NOT_ALLOWED)
|
||||
|
||||
# check if a fresh setup is forced
|
||||
if forceFreshSetup:
|
||||
logging.warning(f"forcing node to fresh setup")
|
||||
setupPhase="setup"
|
||||
|
||||
#### SETUP ####
|
||||
if setupPhase == "setup":
|
||||
if name_valid(hostname) == False:
|
||||
|
|
@ -132,7 +138,8 @@ async def setup_start_done(
|
|||
"setPasswordC=1",
|
||||
f"passwordA='{passwordA}'",
|
||||
f"passwordB='{passwordB}'",
|
||||
f"passwordC='{passwordC}'"
|
||||
f"passwordC='{passwordC}'",
|
||||
""
|
||||
])
|
||||
|
||||
#### RECOVERY ####
|
||||
|
|
@ -146,6 +153,32 @@ async def setup_start_done(
|
|||
f"passwordA='{passwordA}'"
|
||||
])
|
||||
|
||||
#### MIGRATION ####
|
||||
elif setupPhase == "migration":
|
||||
logging.warning(f"check migration data")
|
||||
hddGotMigrationData = await redis_get("hddGotMigrationData")
|
||||
if hddGotMigrationData == "":
|
||||
logging.warning(f"hddGotMigrationData is not available")
|
||||
return HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||
if password_valid(passwordA) == False:
|
||||
logging.warning(f"passwordA is not valid")
|
||||
return HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||
if password_valid(passwordB) == False:
|
||||
logging.warning(f"passwordB is not valid")
|
||||
return HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||
if password_valid(passwordC) == False:
|
||||
logging.warning(f"passwordC is not valid")
|
||||
return HTTPException(status.HTTP_400_BAD_REQUEST)
|
||||
write_text_file(setupFilePath,[
|
||||
f"migrationOS={hddGotMigrationData}",
|
||||
"setPasswordA=1",
|
||||
"setPasswordB=1",
|
||||
"setPasswordC=1",
|
||||
f"passwordA='{passwordA}'",
|
||||
f"passwordB='{passwordB}'",
|
||||
f"passwordC='{passwordC}'"
|
||||
])
|
||||
|
||||
else:
|
||||
logging.warning(f"not handled setupPhase state ({setupPhase})")
|
||||
return HTTPException(status.HTTP_405_METHOD_NOT_ALLOWED)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ async def login(i: LoginInput):
|
|||
# script does not work when called from api yet
|
||||
if password_valid(i.password):
|
||||
result = await call_script(
|
||||
f"/home/admin/config.scripts/blitz.setpassword.sh check-a {i.password}"
|
||||
f"/home/admin/config.scripts/blitz.passwords.sh check a {i.password}"
|
||||
)
|
||||
data = parse_key_value_text(result)
|
||||
if data["correct"] == "1":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue