WebAdmin: refactor template permissions

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2024-11-26 20:39:36 +01:00
parent 0f9314f900
commit d3e76898cd
12 changed files with 372 additions and 465 deletions

View File

@@ -547,6 +547,16 @@ func (a *Admin) HasPermission(perm string) bool {
return slices.Contains(a.Permissions, perm)
}
// HasPermissions returns true if the admin has all the specified permissions
func (a *Admin) HasPermissions(perms ...string) bool {
for _, perm := range perms {
if !a.HasPermission(perm) {
return false
}
}
return len(perms) > 0
}
// GetAllowedIPAsString returns the allowed IP as comma separated string
func (a *Admin) GetAllowedIPAsString() string {
return strings.Join(a.Filters.AllowList, ",")