feat: admin interface: cannot delete self

This commit is contained in:
Settel 2022-03-03 07:19:19 +01:00
parent a89f197fdd
commit b477730140
2 changed files with 7 additions and 0 deletions

View File

@ -29,6 +29,13 @@ func (app *Application) DeletePlayer(usr *user.User, w http.ResponseWriter, r *h
fmt.Fprintf(w, "forbidden") fmt.Fprintf(w, "forbidden")
return return
} }
if deleteUser.GetId() == usr.GetId() {
w.WriteHeader(http.StatusForbidden)
fmt.Printf("can't delete yourself\n")
fmt.Fprintf(w, "forbidden")
return
}
if err := deleteUser.DeleteUser(); err != nil { if err := deleteUser.DeleteUser(); err != nil {
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
fmt.Printf("%v\n", err) fmt.Printf("%v\n", err)