1
0
Fork 0

Make user-unique detection work

master
Dario Ernst 8 years ago
parent 4c3a8d5ad7
commit b7b508d703

@ -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)

Loading…
Cancel
Save