func DeleteUser(c *gin.Context) { user, err := store.GetUserLogin(c, c.Param("login")) if err != nil { c.String(404, "Cannot find user. %s", err) return } if err = store.DeleteUser(c, user); err != nil { c.String(500, "Error deleting user. %s", err) return } c.String(200, "") }
func DeleteUser(c *gin.Context) { me := session.User(c) user, err := store.GetUserLogin(c, c.Param("login")) if err != nil { c.AbortWithStatus(http.StatusNotFound) return } // cannot delete self if me.ID == user.ID { c.AbortWithStatus(http.StatusForbidden) return } err = store.DeleteUser(c, user) if err != nil { c.AbortWithStatus(http.StatusInternalServerError) return } c.Writer.WriteHeader(http.StatusNoContent) }