From d563afe77b5ef6c29ddb70142db9bd40c0a0bcd8 Mon Sep 17 00:00:00 2001 From: Javier Romero Castro Date: Thu, 9 Nov 2023 15:00:30 +0100 Subject: [PATCH] model: avoid setting value on getter * closes https://github.com/zenodo/rdm-project/issues/521 --- invenio_accounts/models.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/invenio_accounts/models.py b/invenio_accounts/models.py index db81bf71..fe13b76a 100644 --- a/invenio_accounts/models.py +++ b/invenio_accounts/models.py @@ -100,7 +100,7 @@ class User(db.Model, Timestamp, UserMixin): _displayname = db.Column("displayname", db.String(255), nullable=True) """Case-preserving version of the username.""" - _email = db.Column("email", db.String(255), unique=True) + email = db.Column(db.String(255), unique=True) """User email.""" password = db.Column(db.String(255)) @@ -203,16 +203,6 @@ def username(self, username): self._displayname = username self._username = username.lower() - @hybrid_property - def email(self): - """Get email.""" - return self._email - - @email.setter - def email(self, email): - """Set lowercase email.""" - self._email = email.lower() - @hybrid_property def user_profile(self): """Get the user profile.""" @@ -239,7 +229,7 @@ def preferences(self): if self._preferences is None: return None elif not isinstance(self._preferences, UserPreferenceDict): - self._preferences = UserPreferenceDict(**self._preferences) + return UserPreferenceDict(**self._preferences) return self._preferences