Prevent edit user from duplicating email address
This commit is contained in:
parent
49a7fb1007
commit
d6836915bb
@ -189,7 +189,10 @@ class User(UserMixin, db.Model):
|
|||||||
if not password and not email: return False, 'There were no changes requested.'
|
if not password and not email: return False, 'There were no changes requested.'
|
||||||
if password: self.set_password(password)
|
if password: self.set_password(password)
|
||||||
old_email = self.get_email()
|
old_email = self.get_email()
|
||||||
if email: self.set_email(email)
|
if email:
|
||||||
|
for entry in User.query.all():
|
||||||
|
if entry.get_email() == email and not entry == self: return False, f'The email address {email} is already in use.'
|
||||||
|
self.set_email(email)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
write('system.log', f'Information for user {self.get_username()} has been updated by {current_user.get_username()}.')
|
write('system.log', f'Information for user {self.get_username()} has been updated by {current_user.get_username()}.')
|
||||||
if notify:
|
if notify:
|
||||||
|
Loading…
Reference in New Issue
Block a user