diff --git a/ordr2/models/account.py b/ordr2/models/account.py index db98378..86ecdd5 100644 --- a/ordr2/models/account.py +++ b/ordr2/models/account.py @@ -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): 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): ''' 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): 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 ''' diff --git a/ordr2/resources/base.py b/ordr2/resources/base.py index 68de3d5..308e5bc 100644 --- a/ordr2/resources/base.py +++ b/ordr2/resources/base.py @@ -52,7 +52,9 @@ class BaseResource(object): :param str key: path segment for a child resource :rtype: - ordr2.resources.BaseResource or KeyError + subclass of ordr2.resources.base.BaseResource + :raises: + KeyError if path segment is not found ''' node_class = self.nodes[key] return node_class(key, self) diff --git a/ordr2/security.py b/ordr2/security.py index 60336ca..e4d20f4 100644 --- a/ordr2/security.py +++ b/ordr2/security.py @@ -38,7 +38,7 @@ def get_user(request): :type request: pyramid.request.Request :rtype: - ordr2.models.users.User or None + :class:`ordr2.models.account.User` or None ''' user_id = request.unauthenticated_userid if user_id is not None: diff --git a/ordr2/session.py b/ordr2/session.py index 704f356..1996d67 100644 --- a/ordr2/session.py +++ b/ordr2/session.py @@ -1,7 +1,6 @@ ''' Session configuration ''' import binascii -from pyramid.session import BaseCookieSessionFactory from pyramid_nacl_session import EncryptedCookieSessionFactory