fix exist check

This commit is contained in:
Adrian Zürcher
2025-11-07 08:06:54 +01:00
parent 1f60813589
commit 0c37d014a9
5 changed files with 16 additions and 13 deletions

View File

@@ -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)))