diff --git a/ref-test/app/models/user.py b/ref-test/app/models/user.py index a1cec1d..cd945c2 100644 --- a/ref-test/app/models/user.py +++ b/ref-test/app/models/user.py @@ -189,7 +189,10 @@ class User(UserMixin, db.Model): if not password and not email: return False, 'There were no changes requested.' if password: self.set_password(password) 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() write('system.log', f'Information for user {self.get_username()} has been updated by {current_user.get_username()}.') if notify: