mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 02:32:57 +00:00
hot fix #1
This commit is contained in:
@@ -495,6 +495,11 @@ func (ac *AuthController) AdminCreateUser(c *gin.Context) {
|
||||
IsActive: isActive,
|
||||
}
|
||||
if err := ac.DB.Create(&u).Error; err != nil {
|
||||
errStr := err.Error()
|
||||
if strings.Contains(errStr, "duplicate key value") || strings.Contains(errStr, "idx_users_email") {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Email already registered"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to create user"})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user