1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

feat(users): prevent the removal of initial admin account (#3912)

* feat(users): prevent the removal of initial admin account

* feat(users): disabled init admin delete button
This commit is contained in:
Chaim Lev-Ari 2020-06-15 02:48:58 +03:00 committed by GitHub
parent 381e372c4c
commit 24888fbbae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 3 deletions

View file

@ -1,6 +1,7 @@
package users
import (
"errors"
"net/http"
httperror "github.com/portainer/libhttp/error"
@ -17,6 +18,10 @@ func (handler *Handler) userDelete(w http.ResponseWriter, r *http.Request) *http
return &httperror.HandlerError{http.StatusBadRequest, "Invalid user identifier route variable", err}
}
if userID == 1 {
return &httperror.HandlerError{http.StatusForbidden, "Cannot remove the initial admin account", errors.New("Cannot remove the initial admin account")}
}
tokenData, err := security.RetrieveTokenData(r)
if err != nil {
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve user authentication token", err}