aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/models.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--webmentions_ssg/models.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/webmentions_ssg/models.py b/webmentions_ssg/models.py
index b6679e8..f89e587 100644
--- a/webmentions_ssg/models.py
+++ b/webmentions_ssg/models.py
@@ -1,7 +1,7 @@
from __future__ import annotations
import uuid
-from datetime import datetime, timezone
+from datetime import UTC, datetime
from enum import StrEnum
from flask_login import UserMixin
@@ -38,7 +38,12 @@ class User(UserMixin, Base):
def __repr__(self) -> str:
return f"<User {self.username}>"
- def set_password(self, password: str) -> None:
+ @property
+ def password(self) -> None:
+ raise AttributeError("Password is write-only")
+
+ @password.setter
+ def password(self, password: str) -> None:
self.password_hash = generate_password_hash(password)
def check_password(self, password: str) -> bool:
@@ -60,8 +65,8 @@ class ReceivedWebmention(Base):
updated_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
- default=lambda: datetime.now(timezone.utc),
- onupdate=lambda: datetime.now(timezone.utc),
+ default=lambda: datetime.now(UTC),
+ onupdate=lambda: datetime.now(UTC),
nullable=False,
)
@@ -185,4 +190,4 @@ class SentWebmention(Base):
def uuid7_to_datetime(identifier: uuid.UUID) -> datetime:
- return datetime.fromtimestamp(identifier.time / 1000, tz=timezone.utc)
+ return datetime.fromtimestamp(identifier.time / 1000, tz=UTC)