8000 updated · wpcodevo/golang-gorm-postgres@f69443a · GitHub
[go: up one dir, main page]

Skip to content

Commit f69443a

Browse files
committed
updated
1 parent 2ee1aab commit f69443a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

controllers/auth.controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ func (ac *AuthController) SignUpUser(ctx *gin.Context) {
5656

5757
result := ac.DB.Create(&newUser)
5858

59-
if result.Error != nil {
59+
if result.Error != nil && strings.Contains(result.Error.Error(), "duplicate key value violates unique") {
60+
ctx.JSON(http.StatusConflict, gin.H{"status": "fail", "message": "User with that email already exists"})
61+
return
62+
} else if result.Error != nil {
6063
ctx.JSON(http.StatusBadGateway, gin.H{"status": "error", "message": "Something bad happened"})
6164
return
6265
}

0 commit comments

Comments
 (0)
0