Skip to content
Snippets Groups Projects
Verified Commit c65eee53 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

WIP: authentication

parent 34d3ff3c
No related branches found
No related tags found
No related merge requests found
...@@ -186,9 +186,14 @@ class DefaultCaosDBClientDelegate: ...@@ -186,9 +186,14 @@ class DefaultCaosDBClientDelegate:
def find_auth(self, record_type, *args, **kwargs): def find_auth(self, record_type, *args, **kwargs):
if record_type == "caosdb_auth_user": if record_type == "caosdb_auth_user":
name = kwargs["filter"]["elements"][-1]["v"] name = kwargs["filter"]["elements"][-1]["v"]
print("find " + name)
res = self._caosdb.administration._retrieve_user(name) res = self._caosdb.administration._retrieve_user(name)
print(res) columns = ["id", "password", "last_login", "is_superuser",
"username", "first_name", "last_name", "email",
"is_staff", "is_active", "date_joined"]
rows = [(0, None, None, True, "tf", "t", "f", "tf@example.com",
True, True, None,)]
return FindResult(rows, columns)
return FindResult([], [])
def list_record_type_names(self): def list_record_type_names(self):
res = self._caosdb.execute_query("SELECT name FROM RECORDTYPE") res = self._caosdb.execute_query("SELECT name FROM RECORDTYPE")
...@@ -246,6 +251,9 @@ class DefaultCaosDBClientDelegate: ...@@ -246,6 +251,9 @@ class DefaultCaosDBClientDelegate:
c.insert(unique=False) c.insert(unique=False)
return InsertManyResult(c) return InsertManyResult(c)
def update_many_auth(self, record_type: str, filter, update):
return UpdateManyResult([1])
def update_many(self, record_type: str, filter, update): def update_many(self, record_type: str, filter, update):
res = self._find(record_type, filter=filter) res = self._find(record_type, filter=filter)
update_set = update["$set"] update_set = update["$set"]
...@@ -256,6 +264,7 @@ class DefaultCaosDBClientDelegate: ...@@ -256,6 +264,7 @@ class DefaultCaosDBClientDelegate:
if hasattr(val, "isoformat"): if hasattr(val, "isoformat"):
val = val.isoformat() val = val.isoformat()
e.get_property(p).value = val e.get_property(p).value = val
if res:
res.update() res.update()
return UpdateManyResult(res) return UpdateManyResult(res)
...@@ -432,6 +441,8 @@ class CaosDBClient: ...@@ -432,6 +441,8 @@ class CaosDBClient:
------- -------
""" """
LOGGER.debug("update_many(%s, %s)", args, kwargs) LOGGER.debug("update_many(%s, %s)", args, kwargs)
if args[0].startswith("caosdb_auth_"):
return self._delegate.update_many_auth(*args, **kwargs)
return self._delegate.update_many(*args, **kwargs) return self._delegate.update_many(*args, **kwargs)
def drop_record_type(self, *args, **kwargs): def drop_record_type(self, *args, **kwargs):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment