|
|
|
@ -68,7 +68,6 @@ type Unit struct {
|
|
|
|
|
|
|
|
|
|
|
|
var db *gorm.DB
|
|
|
|
var db *gorm.DB
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func getToken(w http.ResponseWriter, r *http.Request) error {
|
|
|
|
func getToken(w http.ResponseWriter, r *http.Request) error {
|
|
|
|
var userInput User
|
|
|
|
var userInput User
|
|
|
|
var userRecord User
|
|
|
|
var userRecord User
|
|
|
|
@ -131,10 +130,11 @@ func register(w http.ResponseWriter, r *http.Request) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
countName := 0; countEmail := 0
|
|
|
|
countName := 0; countEmail := 0
|
|
|
|
db.Model(&User{Name:input.Name}).Count(&countName)
|
|
|
|
db.Model(&User{}).Where("name = ?", input.Name).Count(&countName)
|
|
|
|
db.Model(&User{Email:input.Email}).Count(&countEmail)
|
|
|
|
db.Model(&User{}).Where("email = ?", input.Email).Count(&countEmail)
|
|
|
|
|
|
|
|
log.Println("have countName", countName, "mail", countEmail)
|
|
|
|
if countName != 0 || countEmail != 0{
|
|
|
|
if countName != 0 || countEmail != 0{
|
|
|
|
return ehttp.NewErrorf(http.StatusConflict, "username already exists")
|
|
|
|
return ehttp.NewErrorf(http.StatusConflict, "username or email already exists")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
salt := make([]byte, 64)
|
|
|
|
salt := make([]byte, 64)
|
|
|
|
|