sachet/server/models.py: no more url_for errors in CLI

url_for is now called when requested and not at user init. this means
that creating the user via the CLI doesn't complain about not being in
an active request anymore
This commit is contained in:
dogeystamp 2023-05-28 10:48:28 -04:00
parent 3599e80e77
commit a064bc9802
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38

View File

@ -89,9 +89,13 @@ class User(db.Model):
self.password = self.gen_hash(password)
self.username = username
self.url = url_for("users_blueprint.user_api", username=self.username)
self.register_date = datetime.datetime.now()
@property
def url(self):
"""URL linking to this resource."""
return url_for("users_blueprint.user_api", username=self.username)
def gen_hash(self, psswd):
"""Generates a hash from a password."""
return bcrypt.generate_password_hash(