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