def get_user_by_token(self, user_id, token, token_ts=None, cache=None, cache_ts=None, remember=False, save_session=True):
    'Returns a user based on an authentication token.\n\n        :param user_id:\n            User id.\n        :param token:\n            Authentication token.\n        :param token_ts:\n            Token timestamp, used to perform pre-validation.\n        :param cache:\n            Cached user data (from the session).\n        :param cache_ts:\n            Cache timestamp.\n        :param remember:\n            If True, saves permanent sessions.\n        :param save_session:\n            If True, saves the user in the session if authentication succeeds.\n        :returns:\n            A user dict or None.\n        '
    if (self._user is not None):
        assert ((self._user is not _anon) and (self._user['user_id'] == user_id) and (self._user['token'] == token))
        return self._user_or_none()
    if (cache and cache_ts):
        now = int(time.time())
        valid = ((now - cache_ts) < self.store.config['token_cache_age'])
        if (valid and token_ts):
            valid2 = ((now - token_ts) < self.store.config['token_max_age'])
            valid3 = ((now - token_ts) < self.store.config['token_new_age'])
            valid = (valid2 and valid3)
        if valid:
            self._user = cache
        else:
            cache_ts = None
    if (self._user is None):
        (self._user, token) = self.store.validate_token(user_id, token, token_ts=token_ts)
    if (self._user is None):
        self._user = _anon
    elif save_session:
        if (not token):
            token_ts = None
        self.set_session(self._user, token=token, token_ts=token_ts, cache_ts=cache_ts, remember=remember)
    return self._user_or_none()
Returns a user based on an authentication token.

:param user_id:
    User id.
:param token:
    Authentication token.
:param token_ts:
    Token timestamp, used to perform pre-validation.
:param cache:
    Cached user data (from the session).
:param cache_ts:
    Cache timestamp.
:param remember:
    If True, saves permanent sessions.
:param save_session:
    If True, saves the user in the session if authentication succeeds.
:returns:
    A user dict or None.
def get_user_by_token(self, user_id, token, token_ts=None, cache=None, cache_ts=None, remember=False, save_session=True):
    'Returns a user based on an authentication token.\n\n        :param user_id:\n            User id.\n        :param token:\n            Authentication token.\n        :param token_ts:\n            Token timestamp, used to perform pre-validation.\n        :param cache:\n            Cached user data (from the session).\n        :param cache_ts:\n            Cache timestamp.\n        :param remember:\n            If True, saves permanent sessions.\n        :param save_session:\n            If True, saves the user in the session if authentication succeeds.\n        :returns:\n            A user dict or None.\n        '
    if (self._user is not None):
        assert ((self._user is not _anon) and (self._user['user_id'] == user_id) and (self._user['token'] == token))
        return self._user_or_none()
    if (cache and cache_ts):
        now = int(time.time())
        valid = ((now - cache_ts) < self.store.config['token_cache_age'])
        if (valid and token_ts):
            valid2 = ((now - token_ts) < self.store.config['token_max_age'])
            valid3 = ((now - token_ts) < self.store.config['token_new_age'])
            valid = (valid2 and valid3)
        if valid:
            self._user = cache
        else:
            cache_ts = None
    if (self._user is None):
        (self._user, token) = self.store.validate_token(user_id, token, token_ts=token_ts)
    if (self._user is None):
        self._user = _anon
    elif save_session:
        if (not token):
            token_ts = None
        self.set_session(self._user, token=token, token_ts=token_ts, cache_ts=cache_ts, remember=remember)
    return self._user_or_none()