|
34 | 34 | from .models.packages import Repository |
35 | 35 | from .models.profile import ProfileConfiguration |
36 | 36 | from .models.users import Password, User |
| 37 | +from .models.profile_model import ProfileConfiguration |
| 38 | +from .models.users import User |
37 | 39 | from .output import FormattedOutput |
38 | 40 | from .pacman.config import PacmanConfig |
39 | 41 | from .translationhandler import Language, tr, translation_handler |
40 | | -from .utils.util import get_password |
41 | 42 |
|
42 | 43 |
|
43 | 44 | class GlobalMenu(AbstractMenu[None]): |
@@ -110,16 +111,9 @@ def _get_menu_options(self) -> list[MenuItem]: |
110 | 111 | preview_action=self._prev_hostname, |
111 | 112 | key='hostname', |
112 | 113 | ), |
113 | | - MenuItem( |
114 | | - text=tr('Root password'), |
115 | | - action=self._set_root_password, |
116 | | - preview_action=self._prev_root_pwd, |
117 | | - key='root_enc_password', |
118 | | - ), |
119 | 114 | MenuItem( |
120 | 115 | text=tr('Authentication'), |
121 | 116 | action=self._select_authentication, |
122 | | - value=[], |
123 | 117 | preview_action=self._prev_authentication, |
124 | 118 | key='auth_config', |
125 | 119 | ), |
@@ -230,13 +224,16 @@ def has_superuser() -> bool: |
230 | 224 |
|
231 | 225 | missing = set() |
232 | 226 |
|
| 227 | + item: MenuItem = self._item_group.find_by_key('auth_config') |
| 228 | + auth_config: AuthenticationConfiguration | None = item.value |
| 229 | + |
| 230 | + if (auth_config is None or auth_config.root_enc_password is None) and not has_superuser(): |
| 231 | + missing.add( |
| 232 | + tr('Either root-password or at least 1 user with sudo privileges must be specified'), |
| 233 | + ) |
| 234 | + |
233 | 235 | for item in self._item_group.items: |
234 | | - if item.key in ['root_enc_password', 'users']: |
235 | | - if not check('root_enc_password') and not has_superuser(): |
236 | | - missing.add( |
237 | | - tr('Either root-password or at least 1 user with sudo privileges must be specified'), |
238 | | - ) |
239 | | - elif item.mandatory: |
| 236 | + if item.mandatory: |
240 | 237 | assert item.key is not None |
241 | 238 | if not check(item.key): |
242 | 239 | missing.add(item.text) |
@@ -314,6 +311,9 @@ def _prev_authentication(self, item: MenuItem) -> str | None: |
314 | 311 | auth_config: AuthenticationConfiguration = item.value |
315 | 312 | output = '' |
316 | 313 |
|
| 314 | + if auth_config.root_enc_password: |
| 315 | + output += f'{tr("Root password")}: {auth_config.root_enc_password.hidden()}\n' |
| 316 | + |
317 | 317 | if auth_config.u2f_config: |
318 | 318 | u2f_config = auth_config.u2f_config |
319 | 319 | login_method = u2f_config.u2f_login_method.display_value() |
@@ -400,12 +400,6 @@ def _prev_hostname(self, item: MenuItem) -> str | None: |
400 | 400 | return f'{tr("Hostname")}: {item.value}' |
401 | 401 | return None |
402 | 402 |
|
403 | | - def _prev_root_pwd(self, item: MenuItem) -> str | None: |
404 | | - if item.value is not None: |
405 | | - password: Password = item.value |
406 | | - return f'{tr("Root password")}: {password.hidden()}' |
407 | | - return None |
408 | | - |
409 | 403 | def _prev_parallel_dw(self, item: MenuItem) -> str | None: |
410 | 404 | if item.value is not None: |
411 | 405 | return f'{tr("Parallel Downloads")}: {item.value}' |
@@ -510,10 +504,6 @@ def _prev_profile(self, item: MenuItem) -> str | None: |
510 | 504 |
|
511 | 505 | return None |
512 | 506 |
|
513 | | - def _set_root_password(self, preset: str | None = None) -> Password | None: |
514 | | - password = get_password(text=tr('Root password'), allow_skip=True) |
515 | | - return password |
516 | | - |
517 | 507 | def _select_disk_config( |
518 | 508 | self, |
519 | 509 | preset: DiskLayoutConfiguration | None = None, |
|
0 commit comments