aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility/elasticsearch_tools.py
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2018-01-19 10:38:04 +0300
committerMuriithi Frederick Muriuki2018-01-19 10:38:04 +0300
commit7282e0b47c1c6d12fc4c06a080af07c8e67ca75c (patch)
tree9e2f514c5958bc805a1df5e9cb5819360b9f228c /wqflask/utility/elasticsearch_tools.py
parent63a5c8a42ad02e9126bb207465ff5eca98f6515d (diff)
downloadgenenetwork2-7282e0b47c1c6d12fc4c06a080af07c8e67ca75c.tar.gz
Add save_user() function
* On successful login via OAuth2, save the details of the user in elasticsearch store, to avoid hitting the external provider for the basic details.
Diffstat (limited to 'wqflask/utility/elasticsearch_tools.py')
-rw-r--r--wqflask/utility/elasticsearch_tools.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/wqflask/utility/elasticsearch_tools.py b/wqflask/utility/elasticsearch_tools.py
index bc7bb240..74db489b 100644
--- a/wqflask/utility/elasticsearch_tools.py
+++ b/wqflask/utility/elasticsearch_tools.py
@@ -20,3 +20,10 @@ def get_user_by_unique_column(column_name, column_value):
except TransportError as te:
pass
return user_details
+
+def save_user(user, user_id, index="users", doc_type="local"):
+ es = Elasticsearch([{
+ "host": ELASTICSEARCH_HOST
+ , "port": ELASTICSEARCH_PORT
+ }])
+ es.create(index, doc_type, body=user, id=user_id)