diff options
-rwxr-xr-x | src/wsgi.py | 78 |
1 files changed, 35 insertions, 43 deletions
diff --git a/src/wsgi.py b/src/wsgi.py index 0aff8f4..baa669e 100755 --- a/src/wsgi.py +++ b/src/wsgi.py @@ -53,51 +53,43 @@ class EPGet(CollectorResource): out = list() selectors = dict() + if 'domains' in req.context['user']: + orgs = req.context['user']['domains'] + + limit = 25 + skip = 0 + + if not orgs: + resp.status = falcon.HTTP_401 + resp.text = json.dumps({ + 'status': 'error', + 'message': 'Invalid username or password\n' + }) + + return + + if key: + out = self._db.get(key) + resp.text = json.dumps({'status': 'success', 'data': out}) + return + + for param in req.params: + if param == 'limit': + limit = req.params['limit'] + elif param == 'skip': + skip = req.params['skip'] + for i in index.indexes: + for j in i['index']['fields']: + if j == param: + selectors[param] = req.params[param] + + for org in orgs: + selectors['domain'] = org + data = self._db.search(**selectors, limit=limit, skip=skip) + if data: + out += data -<< << << < HEAD - resp.status = falcon.HTTP_200 - resp.content_type = falcon.MEDIA_JSON - - print(req.context) - if 'domains' in req.context['user']: - orgs = req.context['user']['domains'] -== == == = - limit = 25 - skip = 0 - - orgs = self.user_auth(req.auth, self._users.read_perms) ->>>>>> > main - - if not orgs: - resp.status = falcon.HTTP_401 - resp.text = json.dumps({ - 'status': 'error', - 'message': 'Invalid username or password\n' - }) - return - - if key: - out = self._db.get(key) resp.text = json.dumps({'status': 'success', 'data': out}) - return - - for param in req.params: - if param == 'limit': - limit = req.params['limit'] - elif param == 'skip': - skip = req.params['skip'] - for i in index.indexes: - for j in i['index']['fields']: - if j == param: - selectors[param] = req.params[param] - - for org in orgs: - selectors['domain'] = org - data = self._db.search(**selectors, limit=limit, skip=skip) - if data: - out += data - - resp.text = json.dumps({'status': 'success', 'data': out}) class EPAdd(CollectorResource): |