mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 02:22:44 +01:00
fix(user): trust an admin-saved email only while the user still holds it
Saving an unchanged email as an admin wrote email_trusted=True by id alone, so a user who changed their email between the admin's read and that write had the new address trusted. The trust now goes through a conditional UPDATE matching the address the admin submitted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -130,6 +130,22 @@ class DBUsersHandler(DBBaseHandler):
|
||||
)
|
||||
return session.scalars(select(User).filter_by(id=id)).one()
|
||||
|
||||
@begin_session
|
||||
def trust_email(
|
||||
self,
|
||||
id: int,
|
||||
email: str,
|
||||
session: Session = INJECTED_SESSION,
|
||||
) -> bool:
|
||||
"""Mark the user's email trusted only if it is still `email`."""
|
||||
query = self.filter(update(User), ids=[id], emails=[email])
|
||||
result = session.execute(
|
||||
query.values(email_trusted=True).execution_options(
|
||||
synchronize_session=False
|
||||
)
|
||||
)
|
||||
return affected_rows(result) > 0
|
||||
|
||||
@begin_session
|
||||
def set_ra_progression(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user