Email is unique for people + start work on authelia integration
This commit is contained in:
parent
76981f31c8
commit
aeb43e4775
9 changed files with 82 additions and 4 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue