summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristofer Hallin <kristofer@sunet.se>2021-10-18 15:20:08 +0200
committerKristofer Hallin <kristofer@sunet.se>2021-10-18 15:20:08 +0200
commitbb9afde16d56eb7b5563497003754417de05f3f5 (patch)
tree8c9a101ba27542d14134bae8e7f4421a9d966ad3
parent24fb5eb57531f20d1f394d145833cc31016e86ee (diff)
Fixed merge conflicts.khn.jwt
-rwxr-xr-xsrc/wsgi.py78
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):