From ba28a9ca76ab10774f437fbd2857b49c0668d919 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Thu, 31 Aug 2017 09:22:32 +0200 Subject: [PATCH] Support login with github profiles that have no full name We only really need the email, the rest the user can just fill out manually. So instead of crashing, just leave them empty. --- pgweb/account/oauthclient.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pgweb/account/oauthclient.py b/pgweb/account/oauthclient.py index afa33cfb..48254c0e 100644 --- a/pgweb/account/oauthclient.py +++ b/pgweb/account/oauthclient.py @@ -105,7 +105,12 @@ def oauth_login_github(request): # Github just returns full name, so we're just going to have to # split that. r = oa.get('https://api.github.com/user').json() - n = r['name'].split(None, 1) + if 'name' in r: + n = r['name'].split(None, 1) + else: + # Some github accounts have no name on them, so we can just + # let the user fill it out manually in that case. + n = ['',''] # Email is at a separate endpoint r = oa.get('https://api.github.com/user/emails').json() for e in r: -- 2.39.5