diff options
author | Muriithi Frederick Muriuki | 2018-01-19 10:38:04 +0300 |
---|---|---|
committer | Pjotr Prins | 2018-03-26 09:24:34 +0000 |
commit | 98de7bf9649115b67a13018454a2c3766be1fc12 (patch) | |
tree | 13ed178fbaec7e2775c0ec2507d123a42945a60b | |
parent | 941e42ef72bd6aa6761c35cf78e64df41977c5d3 (diff) | |
download | genenetwork2-98de7bf9649115b67a13018454a2c3766be1fc12.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.
-rw-r--r-- | wqflask/utility/elasticsearch_tools.py | 7 |
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) |