def _read_client_token(self, request_handler): client_id_token = tornado_utils.get_secure_cookie(request_handler, self.COOKIE_KEY) if not client_id_token: return self.EMPTY_TOKEN parts = client_id_token.split('&') if len(parts) != 2: LOGGER.warning('Invalid token structure: ' + client_id_token) return self.EMPTY_TOKEN try: expiry_time = int(parts[1]) except: LOGGER.exception('Invalid expiry time in: ' + client_id_token) return self.EMPTY_TOKEN days_remaining = date_utils.ms_to_days(expiry_time - date_utils.get_current_millis()) if days_remaining < 0: LOGGER.warning('Token seems to be expired: ' + str(expiry_time)) return self.EMPTY_TOKEN return parts[0], days_remaining
def _read_client_token(self, request_handler): client_id_token = tornado_utils.get_secure_cookie( request_handler, self.COOKIE_KEY) if not client_id_token: return self.EMPTY_TOKEN parts = client_id_token.split('&') if len(parts) != 2: LOGGER.warning('Invalid token structure: ' + client_id_token) return self.EMPTY_TOKEN try: expiry_time = int(parts[1]) except: LOGGER.exception('Invalid expiry time in: ' + client_id_token) return self.EMPTY_TOKEN days_remaining = date_utils.ms_to_days(expiry_time - date_utils.get_current_millis()) if days_remaining < 0: LOGGER.warning('Token seems to be expired: ' + str(expiry_time)) return self.EMPTY_TOKEN return parts[0], days_remaining
def _get_current_user(request_handler): return tornado_utils.get_secure_cookie(request_handler, 'username')