fix exist check
This commit is contained in:
@@ -21,7 +21,7 @@ func (aH *AccessHandler) AddDefaultUser() (err error) {
|
||||
email := "zuercher@tecamino.ch"
|
||||
|
||||
// Check if a user with this email already exists
|
||||
if err := aH.dbHandler.Exists(&models.User{}, "email", email, false); err == nil {
|
||||
if aH.dbHandler.Exists(&models.User{}, "email", email, false) {
|
||||
aH.logger.Debug("AddDefaultUser", "user email "+email+" exists already")
|
||||
// Found a user → skip create
|
||||
return nil
|
||||
@@ -59,7 +59,7 @@ func (aH *AccessHandler) AddUser(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Check if a user with this email already exists
|
||||
if err := aH.dbHandler.Exists(&models.User{}, "email", user.Email, false); err == nil {
|
||||
if aH.dbHandler.Exists(&models.User{}, "email", user.Email, false) {
|
||||
// Found a user → skip create
|
||||
aH.logger.Error("AddUser", "user with email "+user.Email+" already exists")
|
||||
c.JSON(http.StatusBadRequest, models.NewJsonMessageResponse(fmt.Sprintf("user with email %s already exists", user.Email)))
|
||||
|
||||
Reference in New Issue
Block a user