dont allow deleting admin

This commit is contained in:
sentriz
2020-03-10 17:47:57 +00:00
parent c394c1b013
commit 52d00de45d
5 changed files with 457 additions and 349 deletions

View File

@@ -184,6 +184,12 @@ func (c *Controller) ServeDeleteUser(r *http.Request) *Response {
func (c *Controller) ServeDeleteUserDo(r *http.Request) *Response {
username := r.URL.Query().Get("user")
user := c.DB.GetUserFromName(username)
if user.IsAdmin {
return &Response{
redirect: "/admin/home",
flashW: []string{"can't delete the admin user"},
}
}
c.DB.Delete(user)
return &Response{redirect: "/admin/home"}
}