refactor(pw): Improve handling of password input
This commit is contained in:
+12
-18
@@ -1,7 +1,6 @@
|
||||
from typing import Optional
|
||||
import getpass
|
||||
import time
|
||||
import colorama
|
||||
|
||||
from commands.util.password_manager import PasswordManager
|
||||
|
||||
|
||||
def choice(default: str, options: str, msg: str) -> str:
|
||||
@@ -33,18 +32,13 @@ def confirm_overwrite(msg: Optional[str] = ""):
|
||||
)
|
||||
|
||||
|
||||
def password(msg: str = ""):
|
||||
pw = ""
|
||||
if msg != "":
|
||||
pw = getpass.getpass(msg)
|
||||
else:
|
||||
pw = getpass.getpass()
|
||||
if pw != "":
|
||||
return pw
|
||||
else:
|
||||
time.sleep(1)
|
||||
print(
|
||||
colorama.Fore.RED + "Error:",
|
||||
colorama.Style.RESET_ALL + "Password cannot be empty",
|
||||
)
|
||||
return password(msg)
|
||||
# Use class to store the password
|
||||
pw_manager = PasswordManager()
|
||||
|
||||
|
||||
def password():
|
||||
return pw_manager.get()
|
||||
|
||||
|
||||
def unlock_sudo():
|
||||
return pw_manager.validate()
|
||||
|
||||
Reference in New Issue
Block a user