get user perms or create them on login

This commit is contained in:
dandds
2018-07-18 10:44:42 -04:00
parent ac150d1af3
commit 0c0aa44468
2 changed files with 56 additions and 42 deletions

View File

@@ -24,10 +24,17 @@ class BaseHandler(tornado.web.RequestHandler):
@tornado.gen.coroutine
def _get_user_permissions(self, user_id):
response = yield self.authz_client.post(
"/users", json={"id": user_id, "atat_role": "ccpo"}
response = yield self.authz_client.get(
"/users/{}".format(user_id), raise_error=False
)
return response.json
if response.code == 404:
response = yield self.authz_client.post(
"/users", json={"id": user_id, "atat_role": "developer"}
)
return response.json
else:
return response.json
def get_current_user(self):
cookie = self.get_secure_cookie("atat")