How to use the jupyterhub.orm.APIToken.find function in jupyterhub

To help you get started, we’ve selected a few jupyterhub examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterhub / jupyterhub / jupyterhub / handlers / base.py View on Github external
def get_current_user_token(self):
        """get_current_user from Authorization header token"""
        token = self.get_auth_token()
        if token is None:
            return None
        orm_token = orm.APIToken.find(self.db, token)
        if orm_token is None:
            return None
        else:
            # record token activity
            now = datetime.utcnow()
            orm_token.last_activity = now
            if orm_token.user:
                orm_token.user.last_activity = now

            self.db.commit()
            return orm_token.service or self._user_from_orm(orm_token.user)