func (auth *AuthController) Signup(c *gin.Context) {

	type signupInfo struct {
		Email     string `json:"email" binding:"required"`
		Password  string `json:"password" binding:"required"`
		Name      string `json:"name"`
		Cpf       string `json:"cpf"`
		Celphone  string `json:"celphone"`
		LastName  string `json:"lastname"`
		Address   string `json:"address"`
		Number    int32  `json:"number"`
		City      string `json:"city"`
		State     string `json:"state"`
		UserAgent string `json:"useragent"`
	}
	var info signupInfo
	fmt.Println("INFO ->>> ", info)
	if err := c.ShouldBindJSON(&info); err != nil {
		c.AbortWithStatusJSON(402, gin.H{"error": "Please input all fields"})
		return
	}
	user := entity.User{}
	user.Email = info.Email
	hash, err := bcrypt.GenerateFromPassword([]byte(info.Password), bcrypt.MinCost)
	if err != nil {
		log.Fatal(err)
		return
	}

	user.Password = string(hash)
	user.Name = info.Name
	user.LastName = info.LastName
	user.Address = info.Address
	user.Number = info.Number
	user.City = info.City
	user.State = info.State
	user.Celphone = info.Celphone
	user.Cpf = info.Cpf
	user.UserAgent = c.GetHeader("User-Agent")
	userservice := service.Userservice{}
	err = userservice.Create(&user)
	if err != nil {
		c.AbortWithStatusJSON(500, gin.H{"error": err.Error()})
	} else {
		c.JSON(200, gin.H{"result": "ok"})
	}
	return
}
//Signup is for user signup
Signup is for user signup
// Signup is for user signup
func (auth *AuthController) Signup(c *gin.Context) {
	type signupInfo struct {
		Email     string `json:"email" binding:"required"`
		Password  string `json:"password" binding:"required"`
		Name      string `json:"name"`
		Cpf       string `json:"cpf"`
		Celphone  string `json:"celphone"`
		LastName  string `json:"lastname"`
		Address   string `json:"address"`
		Number    int32  `json:"number"`
		City      string `json:"city"`
		State     string `json:"state"`
		UserAgent string `json:"useragent"`
	}
	var info signupInfo
	fmt.Println("INFO ->>> ", info)
	if err := c.ShouldBindJSON(&info); err != nil {
		c.AbortWithStatusJSON(402, gin.H{"error": "Please input all fields"})
		return
	}
	user := entity.User{}
	user.Email = info.Email
	hash, err := bcrypt.GenerateFromPassword([]byte(info.Password), bcrypt.MinCost)
	if err != nil {
		log.Fatal(err)
		return
	}
	user.Password = string(hash)
	user.Name = info.Name
	user.LastName = info.LastName
	user.Address = info.Address
	user.Number = info.Number
	user.City = info.City
	user.State = info.State
	user.Celphone = info.Celphone
	user.Cpf = info.Cpf
	user.UserAgent = c.GetHeader("User-Agent")
	userservice := service.Userservice{}
	err = userservice.Create(&user)
	if err != nil {
		c.AbortWithStatusJSON(500, gin.H{"error": err.Error()})
	} else {
		c.JSON(200, gin.H{"result": "ok"})
	}
	return
}
func ( auth * AuthController ) Signup ( c * gin . Context ) { type signupInfo struct { Email string `json:"email" binding:"required"` Password string `json:"password" binding:"required"` Name string `json:"name"` Cpf string `json:"cpf"` Celphone string `json:"celphone"` LastName string `json:"lastname"` Address string `json:"address"` Number int32 `json:"number"` City string `json:"city"` State string `json:"state"` UserAgent string `json:"useragent"` } var info signupInfo fmt . Println ( " " , info ) if err := c . ShouldBindJSON ( & info ) ; err != nil { c . AbortWithStatusJSON ( 402 , gin . H { " " : " " } ) return } user := entity . User { } user . Email = info . Email hash , err := bcrypt . GenerateFromPassword ( [ ] byte ( info . Password ) , bcrypt . MinCost ) if err != nil { log . Fatal ( err ) return } user . Password = string ( hash ) user . Name = info . Name user . LastName = info . LastName user . Address = info . Address user . Number = info . Number user . City = info . City user . State = info . State user . Celphone = info . Celphone user . Cpf = info . Cpf user . UserAgent = c . GetHeader ( " " ) userservice := service . Userservice { } err = userservice . Create ( & user ) if err != nil { c . AbortWithStatusJSON ( 500 , gin . H { " " : err . Error ( ) } ) } else { c . JSON ( 200 , gin . H { " " : " " } ) } return }
Signup is for user signup
Signup is for user signup