mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Prevent adding another user with the same email
This commit is contained in:
parent
a9d1ccde38
commit
1c57a9b2a5
@ -61,19 +61,6 @@ func (m *Model) LoadByEmail(email string) error {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
/*
|
||||
// Touch will update model's timestamp(s)
|
||||
func (m *Model) Touch(created bool) {
|
||||
var d types.DBDate
|
||||
d.Time = time.Now()
|
||||
if created {
|
||||
m.CreatedOn = d
|
||||
}
|
||||
m.ModifiedOn = d
|
||||
m.generateGravatar()
|
||||
}
|
||||
*/
|
||||
|
||||
// Save will save this model to the DB
|
||||
func (m *Model) Save() error {
|
||||
// Ensure email is nice
|
||||
@ -82,8 +69,12 @@ func (m *Model) Save() error {
|
||||
return errors.ErrSystemUserReadonly
|
||||
}
|
||||
|
||||
// Check if an existing user with this email exists
|
||||
if m2, err := GetByEmail(m.Email); err == nil && m.ID != m2.ID {
|
||||
return errors.ErrDuplicateEmailUser
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
// todo: touch? not sure that save does this or not?
|
||||
result := db.Save(m)
|
||||
return result.Error
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user