Handle no U2F device available (#3648)
This commit is contained in:
parent
47f4e63006
commit
231530d5f9
|
|
@ -35,20 +35,13 @@ class AuthenticationMenu(AbstractSubMenu[AuthenticationConfiguration]):
|
|||
return [
|
||||
MenuItem(
|
||||
text=tr('U2F login setup'),
|
||||
action=setup_u2f_login,
|
||||
action=select_u2f_login,
|
||||
value=self._auth_config.u2f_config,
|
||||
preview_action=self._prev_u2f_login,
|
||||
dependencies=[self._depends_on_u2f],
|
||||
key='u2f_config',
|
||||
),
|
||||
]
|
||||
|
||||
def _depends_on_u2f(self) -> bool:
|
||||
devices = Fido2.get_fido2_devices()
|
||||
if not devices:
|
||||
return False
|
||||
return True
|
||||
|
||||
def _prev_u2f_login(self, item: MenuItem) -> str | None:
|
||||
if item.value is not None:
|
||||
u2f_config: U2FLoginConfiguration = item.value
|
||||
|
|
@ -60,10 +53,19 @@ class AuthenticationMenu(AbstractSubMenu[AuthenticationConfiguration]):
|
|||
output += tr('Passwordless sudo: ') + (tr('Enabled') if u2f_config.passwordless_sudo else tr('Disabled'))
|
||||
|
||||
return output
|
||||
|
||||
devices = Fido2.get_fido2_devices()
|
||||
if not devices:
|
||||
return tr('No U2F devices found')
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def setup_u2f_login(preset: U2FLoginConfiguration) -> U2FLoginConfiguration | None:
|
||||
def select_u2f_login(preset: U2FLoginConfiguration) -> U2FLoginConfiguration | None:
|
||||
devices = Fido2.get_fido2_devices()
|
||||
if not devices:
|
||||
return None
|
||||
|
||||
items = []
|
||||
for method in U2FLoginMethod:
|
||||
items.append(MenuItem(method.display_value(), value=method))
|
||||
|
|
|
|||
|
|
@ -36,7 +36,10 @@ class Fido2:
|
|||
|
||||
fido_devices = clear_vt100_escape_codes_from_str(ret)
|
||||
|
||||
for line in fido_devices.split('\r\n'):
|
||||
if not fido_devices:
|
||||
return []
|
||||
|
||||
for line in fido_devices.splitlines():
|
||||
path, details = line.replace(',', '').split(':', maxsplit=1)
|
||||
_, product, manufacturer = details.strip().split(' ', maxsplit=2)
|
||||
|
||||
|
|
|
|||
|
|
@ -1507,7 +1507,7 @@ class Installer:
|
|||
|
||||
parent_dev_path = device_handler.get_parent_device_path(boot_partition.safe_dev_path)
|
||||
|
||||
cmd_template = [
|
||||
cmd_template = (
|
||||
'efibootmgr',
|
||||
'--create',
|
||||
'--disk',
|
||||
|
|
@ -1521,7 +1521,7 @@ class Installer:
|
|||
'--unicode',
|
||||
*cmdline,
|
||||
'--verbose',
|
||||
]
|
||||
)
|
||||
|
||||
for kernel in self.kernels:
|
||||
# Setup the firmware entry
|
||||
|
|
|
|||
Loading…
Reference in New Issue