Email is unique for people + start work on authelia integration

This commit is contained in:
William Bouzourène 2026-03-13 14:42:40 +01:00
parent 76981f31c8
commit aeb43e4775
Signed by: bouzoure
GPG key ID: 423440D735B56BE2
9 changed files with 82 additions and 4 deletions

View file

@ -495,6 +495,18 @@ func ContactAdd(c *fiber.Ctx) error {
person.PostalCode = data.PostalCode
person.City = data.City
if len(data.Email) > 0 {
var personEmail []models.Person
result := db.Find(&personEmail, "LOWER(email) = LOWER(?)", data.Email)
if result.Error != nil {
return result.Error
}
if result.RowsAffected > 0 {
errors = append(errors, "L'adresse email est déjà utilisée par un membre ou un sympathisant")
}
}
sectionID, err := strconv.ParseUint(data.Section, 10, 0)
if err == nil {
for _, section := range sections {
@ -744,6 +756,18 @@ func ContactEdit(c *fiber.Ctx) error {
person.PostalCode = data.PostalCode
person.City = data.City
if len(data.Email) > 0 {
var personEmail []models.Person
result := db.Find(&personEmail, "LOWER(email) = LOWER(?)", data.Email)
if result.Error != nil {
return result.Error
}
if result.RowsAffected > 0 {
errors = append(errors, "L'adresse email est déjà utilisée par un membre ou un sympathisant")
}
}
sectionID, err := strconv.ParseUint(data.Section, 10, 0)
if err == nil {
for _, section := range sections {