summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-04-10 16:15:01 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-04-10 16:15:01 -0700
commitf87c5482386c0df4e59f033c98db672ec6d0e370 (patch)
tree417c2d2066343981eb4cfa20cb9d49382de0e8dc /python
parent3d1ad4d5339e6ae06adf7c24061716052daa16cc (diff)
downloadfatcat-f87c5482386c0df4e59f033c98db672ec6d0e370.tar.gz
fatcat-f87c5482386c0df4e59f033c98db672ec6d0e370.zip
bugfix and special case for orcid logins
Diffstat (limited to 'python')
-rw-r--r--python/fatcat_web/auth.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/python/fatcat_web/auth.py b/python/fatcat_web/auth.py
index 44a03f5f..06c8475b 100644
--- a/python/fatcat_web/auth.py
+++ b/python/fatcat_web/auth.py
@@ -54,10 +54,15 @@ def handle_oauth(remote, token, user_info):
# not sure all loginpass backends will set it
if user_info.get('preferred_username'):
preferred_username = user_info['preferred_username']
+ elif 'orcid.org' in iss:
+ # as a special case, prefix ORCiD identifier so it can be used as a
+ # username. If we instead used the human name, we could have
+ # collisions. Not a great user experience either way.
+ preferred_username = 'i' + user_info['sub'].replace('-', '')
else:
preferred_username = user_info['sub']
- params = fatcat_client.AuthOidc(remote.name, user_info['sub'], iss, user_info['preferred_username'])
+ params = fatcat_client.AuthOidc(remote.name, user_info['sub'], iss, preferred_username)
# this call requires admin privs
(resp, http_status, http_headers) = priv_api.auth_oidc_with_http_info(params)
editor = resp.editor