|
|
|
@ -85,7 +85,7 @@ class User(Base):
@@ -85,7 +85,7 @@ class User(Base):
|
|
|
|
|
username = Column(Text, nullable=False, unique=True) |
|
|
|
|
#: hashed password, see :mod:`ordr2.security` |
|
|
|
|
password_hash = Column(Text, nullable=False) |
|
|
|
|
#: role of the user, see :class:`ordr2.models.users.Role` |
|
|
|
|
#: role of the user, see :class:`ordr2.models.account.Role` |
|
|
|
|
role = Column(Enum(Role), nullable=False) |
|
|
|
|
|
|
|
|
|
first_name = Column(Text, nullable=False) |
|
|
|
@ -159,8 +159,8 @@ class User(Base):
@@ -159,8 +159,8 @@ class User(Base):
|
|
|
|
|
what the token is used for |
|
|
|
|
:type subject: |
|
|
|
|
ordr2.models.account.TokenSubject |
|
|
|
|
:param **payload: |
|
|
|
|
etra data to store with the token, must be JSON serializable |
|
|
|
|
:param payload: |
|
|
|
|
extra data to store with the token, must be JSON serializable |
|
|
|
|
:rtype: |
|
|
|
|
(str) unique hash to access the token |
|
|
|
|
''' |
|
|
|
@ -176,11 +176,23 @@ class Token(Base):
@@ -176,11 +176,23 @@ class Token(Base):
|
|
|
|
|
''' Tokens for mail change, account verification and password reset ''' |
|
|
|
|
|
|
|
|
|
__tablename__ = 'tokens' |
|
|
|
|
|
|
|
|
|
#: hash identifyer of the token |
|
|
|
|
hash = Column(Unicode, primary_key=True) |
|
|
|
|
|
|
|
|
|
#: :class:`ordr2.models.account.TokenSubject` |
|
|
|
|
subject = Column(Enum(TokenSubject), nullable=False) |
|
|
|
|
|
|
|
|
|
#: token expires at this date and time |
|
|
|
|
expires = Column(DateTime, nullable=False) |
|
|
|
|
|
|
|
|
|
#: additional data to attach to a token |
|
|
|
|
payload = Column(JsonEncoder, nullable=False) |
|
|
|
|
|
|
|
|
|
#: the user_id the token belongs to |
|
|
|
|
owner_id = Column(Integer, ForeignKey('users.id')) |
|
|
|
|
|
|
|
|
|
#: the user the token belongs to |
|
|
|
|
owner = relationship('User', back_populates='tokens') |
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@ -207,8 +219,8 @@ class Token(Base):
@@ -207,8 +219,8 @@ class Token(Base):
|
|
|
|
|
account the token is issued for |
|
|
|
|
:type subject: |
|
|
|
|
ordr2.models.account.User |
|
|
|
|
:param **payload: |
|
|
|
|
etra data to store with the token, must be JSON serializable |
|
|
|
|
:param payload: |
|
|
|
|
extra data to store with the token, must be JSON serializable |
|
|
|
|
:rtype: |
|
|
|
|
ordr2.models.account.Token |
|
|
|
|
''' |
|
|
|
|