diff --git a/server/main.go b/server/main.go index a59e96d..e7e31bd 100644 --- a/server/main.go +++ b/server/main.go @@ -68,7 +68,6 @@ type Unit struct { var db *gorm.DB - func getToken(w http.ResponseWriter, r *http.Request) error { var userInput User var userRecord User @@ -131,10 +130,11 @@ func register(w http.ResponseWriter, r *http.Request) error { } countName := 0; countEmail := 0 - db.Model(&User{Name:input.Name}).Count(&countName) - db.Model(&User{Email:input.Email}).Count(&countEmail) + db.Model(&User{}).Where("name = ?", input.Name).Count(&countName) + db.Model(&User{}).Where("email = ?", input.Email).Count(&countEmail) + log.Println("have countName", countName, "mail", countEmail) 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)