Exemplo n.º 1
0
func (this *RegisterController) Post() {
	this.Forbbiden("not", "guest")

	user := models.User{}

	username := this.GetString("username")
	password := this.GetString("password")
	email := this.GetString("email")
	nickname := this.GetString("nickname")

	id, err := user.Register(username, password, email, nickname)
	if err != nil {
		this.Data["json"] = map[string]interface{}{
			"result": false,
			"msg":    fmt.Sprintf("%s", err),
			"refer":  nil,
		}
	} else {
		this.Data["json"] = map[string]interface{}{
			"result": true,
			"msg":    fmt.Sprintf("successfully registered, id [%d]", id),
			"refer":  nil,
		}
	}

	this.ServeJson()
}