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

This commit is contained in:
Deluan committed 2021-05-02 17:11:12 -04:00
1 parent 2ff1c79b64
commit 7feda4bea4
6 files changed
+22

No files matched your search

+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
}