def _validate_recaptcha(self, response, remote_addr): """Performs the actual validation.""" try: private_key = flaskbb_config['RECAPTCHA_PRIVATE_KEY'] except KeyError: raise RuntimeError("No RECAPTCHA_PRIVATE_KEY config set") data = url_encode({ 'secret': private_key, 'remoteip': remote_addr, 'response': response }) http_response = http.urlopen(RECAPTCHA_VERIFY_SERVER, to_bytes(data)) if http_response.code != 200: return False json_resp = json.loads(to_unicode(http_response.read())) if json_resp["success"]: return True for error in json_resp.get("error-codes", []): if error in RECAPTCHA_ERROR_CODES: raise ValidationError(RECAPTCHA_ERROR_CODES[error]) return False
def get_online_users(guest=False): # pragma: no cover """Returns all online users within a specified time range :param guest: If True, it will return the online guests """ current = int(time.time()) // 60 minutes = range_method(flaskbb_config["ONLINE_LAST_MINUTES"]) if guest: users = redis_store.sunion( ["online-guests/%d" % (current - x) for x in minutes]) else: users = redis_store.sunion( ["online-users/%d" % (current - x) for x in minutes]) return [to_unicode(u) for u in users]
def get_online_users(guest=False): # pragma: no cover """Returns all online users within a specified time range :param guest: If True, it will return the online guests """ current = int(time.time()) // 60 minutes = range_method(flaskbb_config['ONLINE_LAST_MINUTES']) if guest: users = redis_store.sunion(['online-guests/%d' % (current - x) for x in minutes]) else: users = redis_store.sunion(['online-users/%d' % (current - x) for x in minutes]) return [to_unicode(u) for u in users]