Ejemplo n.º 1
0
//UserDelete handles POST /admin/users/:id/delete route
func UserDelete(c *gin.Context) {
	user, _ := models.GetUser(c.Param("id"))
	if err := user.Delete(); err != nil {
		c.HTML(http.StatusInternalServerError, "errors/500", nil)
		logrus.Error(err)
		return
	}
	c.Redirect(http.StatusFound, "/admin/users")
}
Ejemplo n.º 2
0
//SharedData fills in common data, such as user info, etc...
func SharedData() gin.HandlerFunc {
	return func(c *gin.Context) {
		session := sessions.Default(c)
		if uID := session.Get("UserID"); uID != nil {
			user, _ := models.GetUser(uID)
			if user.ID != 0 {
				c.Set("User", user)
			}
		}
		if system.GetConfig().SignupEnabled {
			c.Set("SignupEnabled", true)
		}
		c.Next()
	}
}
Ejemplo n.º 3
0
//UserEdit handles GET /admin/users/:id/edit route
func UserEdit(c *gin.Context) {
	user, _ := models.GetUser(c.Param("id"))
	if user.ID == 0 {
		c.HTML(http.StatusNotFound, "errors/404", nil)
		return
	}
	h := helpers.DefaultH(c)
	h["Title"] = "Edit user"
	h["Active"] = "users"
	h["User"] = user
	session := sessions.Default(c)
	h["Flash"] = session.Flashes()
	session.Save()
	c.HTML(http.StatusOK, "users/form", h)
}