Further fixes for Github names with just one name
authorMagnus Hagander <magnus@hagander.net>
Thu, 31 Aug 2017 07:25:04 +0000 (09:25 +0200)
committerMagnus Hagander <magnus@hagander.net>
Thu, 31 Aug 2017 07:25:04 +0000 (09:25 +0200)
Not only can they be without names, they can be a one word name which
would cause a different crash. Again, allow that through and let the
user make manual adjustments if they wish.

pgweb/account/oauthclient.py

index 48254c0ed917f39c5a5522723c97b7fb0f120513..ae17bbdd5bb77379c4b44c6a0c20e9dfb0d9736b 100644 (file)
@@ -107,6 +107,10 @@ def oauth_login_github(request):
                r = oa.get('https://api.github.com/user').json()
                if 'name' in r:
                        n = r['name'].split(None, 1)
+                       # Some accounts only have one name, extend with an empty
+                       # lastname, so the user can fill it out manually.
+                       while len(n) < 2:
+                               n.append('')
                else:
                        # Some github accounts have no name on them, so we can just
                        # let the user fill it out manually in that case.