We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parent59a380c commit0a9c03eCopy full SHA for 0a9c03e
controllers/auth.controller.go
@@ -56,11 +56,10 @@ func (ac *AuthController) SignUpUser(ctx *gin.Context) {
56
57
result:=ac.DB.Create(&newUser)
58
59
-ifresult.Error!=nil {
60
-ifstrings.Contains(result.Error.Error(),"duplicate key") {
61
-ctx.JSON(http.StatusConflict, gin.H{"status":"fail","message":"User with that email already exists"})
62
-return
63
-}
+ifresult.Error!=nil&&strings.Contains(result.Error.Error(),"duplicate key value violates unique") {
+ctx.JSON(http.StatusConflict, gin.H{"status":"fail","message":"User with that email already exists"})
+return
+}elseifresult.Error!=nil {
64
ctx.JSON(http.StatusBadGateway, gin.H{"status":"error","message":"Something bad happened"})
65
return
66
}