|
@ -1,3 +1,4 @@ |
|
|
|
|
|
from datetime import datetime |
|
|
from werkzeug.security import generate_password_hash, check_password_hash |
|
|
from werkzeug.security import generate_password_hash, check_password_hash |
|
|
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer |
|
|
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer |
|
|
from itsdangerous import BadSignature |
|
|
from itsdangerous import BadSignature |
|
@ -75,6 +76,11 @@ class User(UserMixin, db.Model): |
|
|
role_id = db.Column(db.Integer, db.ForeignKey('roles.id')) |
|
|
role_id = db.Column(db.Integer, db.ForeignKey('roles.id')) |
|
|
password_hash = db.Column(db.String(128)) |
|
|
password_hash = db.Column(db.String(128)) |
|
|
confirmed = db.Column(db.Boolean, default=False) |
|
|
confirmed = db.Column(db.Boolean, default=False) |
|
|
|
|
|
name = db.Column(db.String(64)) |
|
|
|
|
|
location = db.Column(db.String(64)) |
|
|
|
|
|
about_me = db.Column(db.Text()) |
|
|
|
|
|
member_since = db.Column(db.DateTime(), default=datetime.utcnow) |
|
|
|
|
|
last_seen = db.Column(db.DateTime(), default=datetime.utcnow) |
|
|
|
|
|
|
|
|
def __init__(self, **kwargs): |
|
|
def __init__(self, **kwargs): |
|
|
super(User, self).__init__(**kwargs) |
|
|
super(User, self).__init__(**kwargs) |
|
@ -157,6 +163,11 @@ class User(UserMixin, db.Model): |
|
|
def is_administrator(self): |
|
|
def is_administrator(self): |
|
|
return self.can(Permission.ADMIN) |
|
|
return self.can(Permission.ADMIN) |
|
|
|
|
|
|
|
|
|
|
|
def ping(self): |
|
|
|
|
|
self.last_seen = datetime.utcnow() |
|
|
|
|
|
db.session.add(self) |
|
|
|
|
|
db.session.commit() |
|
|
|
|
|
|
|
|
def __repr__(self): |
|
|
def __repr__(self): |
|
|
return '<User %r>' % self.username |
|
|
return '<User %r>' % self.username |
|
|
|
|
|
|
|
|