We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 06db85d + 0a9c03e commit 0ebd37fCopy full SHA for 0ebd37f
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