mirror of
https://gitcode.com/JianFeeeee/webui4frpc.git
synced 2026-10-15 12:14:37 +00:00
Merge remote-tracking branch 'origin/main'
# Conflicts: # internal/httpapi/dist/assets/index-CL42Ur3_.css # internal/httpapi/dist/assets/index-CbqC9m-j.js # internal/httpapi/dist/assets/index-RFHYrCiX.css # internal/httpapi/dist/assets/index-jvouiCgh.css # internal/httpapi/dist/index.html # internal/store/store.go # web/src/api.ts # web/src/views/ClusterView.vue
This commit is contained in:
@ -93,8 +93,8 @@ func (h *Handler) handleUserByName(w http.ResponseWriter, r *http.Request) {
|
||||
if req.Enabled != nil {
|
||||
enabled = *req.Enabled
|
||||
}
|
||||
// Guard: never disable/demote the last admin.
|
||||
if u.Role == "admin" && (role != "admin" || !enabled) {
|
||||
// Guard: never disable/demote the last admin or superadmin.
|
||||
if (u.Role == "admin" || u.Role == "superadmin") && (role != u.Role || !enabled) {
|
||||
n, _ := h.Store.CountAdmins()
|
||||
if n <= 1 {
|
||||
http.Error(w, "cannot demote or disable the last admin", http.StatusConflict)
|
||||
@ -112,7 +112,7 @@ func (h *Handler) handleUserByName(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "system user is managed by -user/-password flags", http.StatusConflict)
|
||||
return
|
||||
}
|
||||
if u.Role == "admin" {
|
||||
if u.Role == "admin" || u.Role == "superadmin" {
|
||||
n, _ := h.Store.CountAdmins()
|
||||
if n <= 1 {
|
||||
http.Error(w, "cannot delete the last admin", http.StatusConflict)
|
||||
|
||||
Reference in New Issue
Block a user