Skip to content

Commit ef4d7cf

Browse files
authored
Move auth config helpers to AuthenticationConfiguration class (#4340)
1 parent 603c432 commit ef4d7cf

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

archinstall/lib/global_menu.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,25 +203,15 @@ def check(s: str) -> bool:
203203
item = self._item_group.find_by_key(s)
204204
return item.has_value()
205205

206-
def has_superuser() -> bool:
207-
if auth_config and auth_config.users:
208-
return any([u.sudo for u in auth_config.users])
209-
return False
210-
211-
def has_regular_user() -> bool:
212-
if auth_config and auth_config.users:
213-
return len(auth_config.users) > 0
214-
return False
215-
216206
missing = set()
217207

218-
if (auth_config is None or auth_config.root_enc_password is None) and not has_superuser():
208+
if (auth_config is None or auth_config.root_enc_password is None) and not (auth_config and auth_config.has_superuser()):
219209
missing.add(
220210
tr('Either root-password or at least 1 user with sudo privileges must be specified'),
221211
)
222212

223213
# These greeters only show users with UID >= 1000 and have no manual login by default
224-
if not has_regular_user():
214+
if not (auth_config and auth_config.has_regular_user()):
225215
profile_item: MenuItem = self._item_group.find_by_key('profile_config')
226216
profile_config: ProfileConfiguration | None = profile_item.value
227217

archinstall/lib/models/authentication.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,9 @@ def json(self) -> AuthenticationSerialization:
8282
config['u2f_config'] = self.u2f_config.json()
8383

8484
return config
85+
86+
def has_superuser(self) -> bool:
87+
return any(u.sudo for u in self.users)
88+
89+
def has_regular_user(self) -> bool:
90+
return len(self.users) > 0

0 commit comments

Comments
 (0)