mirror of
https://github.com/xiaoxinpro/nginx-proxy-manager-zh.git
synced 2025-03-16 02:28:15 -04: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
|
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
|
// Save will save this model to the DB
|
||||||
func (m *Model) Save() error {
|
func (m *Model) Save() error {
|
||||||
// Ensure email is nice
|
// Ensure email is nice
|
||||||
@ -82,8 +69,12 @@ func (m *Model) Save() error {
|
|||||||
return errors.ErrSystemUserReadonly
|
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()
|
db := database.GetDB()
|
||||||
// todo: touch? not sure that save does this or not?
|
|
||||||
result := db.Save(m)
|
result := db.Save(m)
|
||||||
return result.Error
|
return result.Error
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user