There was an error while loading. Please reload this page.
1 parent 59a380c commit 0a9c03eCopy 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
-if result.Error != nil {
60
-if strings.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
-}
+if result.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
+} else if result.Error != nil {
64
ctx.JSON(http.StatusBadGateway, gin.H{"status": "error", "message": "Something bad happened"})
65
return
66
}
0 commit comments