示例#1
0
文件: c_user.go 项目: yubo/falcon
// @Title Get
// @Description get user by id
// @Param	id		path 	int	true		"The key for staticblock"
// @Success {code:200, data:object} models.User
// @Failure {code:int, msg:string}
// @router /:id [get]
func (c *UserController) GetUser() {
	id, err := c.GetInt(":id")
	if err != nil {
		c.SendMsg(403, err.Error())
	} else {
		user, err := models.GetUser(id)
		if err != nil {
			c.SendMsg(403, err.Error())
		} else {
			c.SendObj(200, user)
		}
	}
}
示例#2
0
文件: web.go 项目: yubo/falcon
func profileFilter(ctx *context.Context) {
	if id, ok := ctx.Input.Session("uid").(int); ok {
		me, err := models.GetUser(id)
		if err != nil {
			return
		}
		ctx.Input.SetData("me", me)
		/*
			if me.Name == "" &&
				!strings.HasPrefix(ctx.Request.URL.String(),
					"/settings") {
				beego.Debug("Redirect /settings/profile")
				ctx.Redirect(302, "/settings/profile")
				return
			}
		*/
	}
}
示例#3
0
文件: c_user.go 项目: yubo/falcon
func (c *MainController) EditUser() {
	var user *models.User

	id, err := c.GetInt(":id")
	if err != nil {
		goto out
	}

	user, err = models.GetUser(id)
	if err != nil {
		goto out
	}

	c.Data["Me"], _ = c.Ctx.Input.GetData("me").(*models.User)
	c.Data["User"] = user
	c.Data["H1"] = "edit user"
	c.Data["Method"] = "put"
	c.TplName = "user/edit.tpl"
	return
out:
	c.SendMsg(400, err.Error())
}