def generate_auth_token(self):
"""Generate an auth token and save it to the `current_auth_token` column."""
alphabet = string.ascii_letters + string.digits
new_auth_token = ''.join(secrets.choice(alphabet) for i in range(32))
self.current_auth_token = new_auth_token
self.last_action = datetime.utcnow()
db.session.add(self)
db.session.commit()
return new_auth_token
评论列表
文章目录