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:
parent
3599e80e77
commit
a064bc9802
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user