Don't crash on completely empty github names
authorMagnus Hagander <magnus@hagander.net>
Mon, 18 Sep 2017 16:31:48 +0000 (18:31 +0200)
committerMagnus Hagander <magnus@hagander.net>
Mon, 18 Sep 2017 16:31:48 +0000 (18:31 +0200)
Sometimes you get a name but it's NULL, sometimes you don't get one. Yay
for consistency, but handle both cases.

pgweb/account/oauthclient.py

index ff071a5ae5df00a860394425f458b646a7f7533b..76f0972288da73e234f9fb9e4e8bec16949ee11f 100644 (file)
@@ -109,7 +109,7 @@ 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()
-               if 'name' in r:
+               if 'name' in r and r['name']:
                        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.