Add EnableUserEditing, to control whether a regular user can change their own details (default true)

This commit is contained in:
Deluan
2021-05-02 17:10:56 -04:00
parent 2ff1c79b64
commit 7feda4bea4
6 changed files with 22 additions and 0 deletions
+5
View File
@@ -4,6 +4,8 @@ import (
"context"
"time"
"github.com/navidrome/navidrome/conf"
. "github.com/Masterminds/squirrel"
"github.com/astaxie/beego/orm"
"github.com/deluan/rest"
@@ -145,6 +147,9 @@ func (r *userRepository) Update(entity interface{}, cols ...string) error {
return rest.ErrPermissionDenied
}
if !usr.IsAdmin {
if !conf.Server.EnableUserEditing {
return rest.ErrPermissionDenied
}
u.IsAdmin = false
u.UserName = usr.UserName
}