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
|
|
@ -18,7 +18,7 @@ import (
|
|||
type PersonValidation struct {
|
||||
LastName string `validate:"max=100"`
|
||||
FirstName string `validate:"required,min=1,max=100"`
|
||||
Email string `validate:"max=100"`
|
||||
Email string `validate:"max=100,email"`
|
||||
Phone string `validate:"max=100"`
|
||||
Mobile string `validate:"max=100"`
|
||||
Address1 string `validate:"max=100"`
|
||||
|
|
@ -498,6 +498,18 @@ func MemberAdd(c *fiber.Ctx) error {
|
|||
}
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
person.IsContact = false
|
||||
person.IsMember = true
|
||||
person.LastName = data.LastName
|
||||
|
|
@ -747,6 +759,18 @@ func MemberEdit(c *fiber.Ctx) error {
|
|||
}
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
person.IsContact = false
|
||||
person.IsMember = true
|
||||
person.LastName = data.LastName
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue