admin/accounts: show icon for accounts with (possibly inherited) admin access

Massimo Melina committed Mar 8, 2022 at 10:09 UTC 1c7cb5ad799172d4ec0da03399d4aff560f15469
3 files changed +4 -7
admin/src/AccountsPage.ts
+2 -1
@@ -161,7 +161,8 @@ function AccountForm({ account, done, groups, config }: { account: Account, grou
161 helperText: values.ignore_limits ? "Speed limits don't apply to this account" : "Speed limits apply to this account" },
162 { k: 'admin', comp: BoolField, fromField: (v:boolean) => v||null, label: "Permission to access Admin interface",
163 helperText: "It's THIS interface you are using right now."
164 - + (config.admin_login ? '' : " You are currently giving free access without login. You can force login in Configuration page.")
164 + + (config?.admin_login ? '' : " You are currently giving free access without login. You can require login in Configuration page."),
165 + ...account.adminActualAccess && { value: true, disabled: true, helperText: "This permission is inherited" },
166 },
167 { k: 'redirect', comp: StringField, helperText: "If you want this account to be redirected to a specific folder/address at login time" },
168 { k: 'belongs', comp: MultiSelectField, label: "Inherits from", options: belongsOptions,
server/src/api.accounts.ts
+2 -5
@@ -24,12 +24,9 @@ const apis: ApiHandlers = {
24 get_accounts() {
25 return {
26 list: Object.values(getAccounts()).map(ac => ({
27 - ...ac,
28 - username: ac.username, // it's hidden and won't be copied by the spread operator
27 + ..._.pick(ac, ['username','ignore_limits','redirects','belongs','admin']),
28 hasPassword: accountHasPassword(ac),
30 - password: undefined,
31 - hashed_password: undefined,
32 - srp: undefined,
29 + adminActualAccess: accountCanLogin(ac) && getFromAccount(ac, a => a.admin),
30 }))
31 }
32 },
todo.md
-1
@@ -1,5 +1,4 @@
1 # To do
2 -- admin/accounts: show icon for accounts with (possibly inherited) admin access
2 - expose admin at same port of frontend
3 - admin: improve masks editor
4 - if specified config is a folder, check for file config.yaml inside