

def get_user(self, request, user_id=None, token_id=None, username=None, email=None, auth_key=None, **kw):
    'Securely fetch a user by id, username, email or auth key\n\n        Returns user or nothing\n        '
    odm = request.app.odm()
    now = datetime.utcnow()
    if (token_id and user_id):
        with odm.begin() as session:
            query = session.query(odm.token)
            query = query.filter_by(user_id=user_id, id=token_id)
            query.update({
                'last_access': now,
            }, synchronize_session=False)
            if (not query.count()):
                return
    if auth_key:
        with odm.begin() as session:
            query = session.query(odm.registration)
            reg = token_id.get(auth_key)
            if (reg and (reg.expiry > now)):
                if (not reg.confirmed):
                    user_id = reg.user_id
            else:
                return
    with odm.begin() as session:
        query = session.query(odm.user)
        try:
            if user_id:
                user = query.get(user_id)
            elif username:
                user = query.filter_by(username=username).one()
            elif email:
                user = query.filter_by(email=normalise_email(email)).one()
            else:
                return
        except NoResultFound:
            return
    return user

dataset/ETHPy150Open quantmind/lux/lux/extensions/auth/backends.py AuthMixin.get_user/VarMisuse@165/243 `query`->`token_id`