Allow skip on password confirmation (#4273)

This commit is contained in:
Daniel Girtler 2026-03-21 17:57:17 +11:00 committed by GitHub
parent e06dd6299f
commit 8d6c56ca2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 6 deletions

View File

@ -501,7 +501,7 @@ class ArchConfigHandler:
lambda p=prompt: get_password( # type: ignore[misc] lambda p=prompt: get_password( # type: ignore[misc]
header=p, header=p,
allow_skip=False, allow_skip=False,
skip_confirmation=True, no_confirmation=True,
) )
) )

View File

@ -13,7 +13,7 @@ async def get_password(
header: str | None = None, header: str | None = None,
allow_skip: bool = False, allow_skip: bool = False,
preset: str | None = None, preset: str | None = None,
skip_confirmation: bool = False, no_confirmation: bool = False,
) -> Password | None: ) -> Password | None:
def password_hint(value: str) -> InputInfo | None: def password_hint(value: str) -> InputInfo | None:
if not value: if not value:
@ -51,7 +51,7 @@ async def get_password(
password = Password(plaintext=result.get_value()) password = Password(plaintext=result.get_value())
break break
if skip_confirmation: if no_confirmation:
return password return password
confirmation_header = f'{tr("Password")}: {password.hidden()}\n\n' confirmation_header = f'{tr("Password")}: {password.hidden()}\n\n'
@ -62,13 +62,16 @@ async def get_password(
return tr('The password did not match, please try again') return tr('The password did not match, please try again')
return None return None
_ = await Input( result = await Input(
header=confirmation_header, header=confirmation_header,
allow_skip=False, allow_skip=allow_skip,
password=True, password=True,
validator_callback=_validate, validator_callback=_validate,
).show() ).show()
if result.type_ == ResultType.Skip:
return None
return password return password

View File

@ -45,7 +45,7 @@ class UserList(ListManager[User]):
elif action == self._actions[1] and entry: # change password elif action == self._actions[1] and entry: # change password
header = f'{tr("User")}: {entry.username}\n' header = f'{tr("User")}: {entry.username}\n'
header += tr('Enter new password') header += tr('Enter new password')
new_password = await get_password(header=header) new_password = await get_password(header=header, allow_skip=True)
if new_password: if new_password:
user = next(filter(lambda x: x == entry, data)) user = next(filter(lambda x: x == entry, data))