don't allow admins to change their own permissions

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2024-11-09 20:24:35 +01:00
parent 30fb1d6240
commit ef98ee7d11
7 changed files with 24 additions and 33 deletions

View File

@@ -3156,9 +3156,9 @@ func (s *httpdServer) handleWebUpdateAdminPost(w http.ResponseWriter, r *http.Re
return
}
if username == claims.Username {
if claims.isCriticalPermRemoved(updatedAdmin.Permissions) {
if !util.SlicesEqual(admin.Permissions, updatedAdmin.Permissions) {
s.renderAddUpdateAdminPage(w, r, &updatedAdmin,
util.NewI18nError(errors.New("you cannot remove these permissions to yourself"),
util.NewI18nError(errors.New("you cannot change your permissions"),
util.I18nErrorAdminSelfPerms,
), false)
return