Handle OAuth providers that return NULL for first or last name
authorMagnus Hagander <magnus@hagander.net>
Wed, 4 Jul 2018 17:40:34 +0000 (19:40 +0200)
committerMagnus Hagander <magnus@hagander.net>
Wed, 4 Jul 2018 17:41:26 +0000 (19:41 +0200)
We already handled those that returns empty, but it appears that at
least Microsoft can also return null/None. If those show up, just treat
them as empty.

pgweb/account/oauthclient.py

index 7fcf8c1716dd497446024adbc27882815505294a..67dc4d9a28b1ff968b7a3a7dd2eb6dd39fda6f5f 100644 (file)
@@ -53,8 +53,8 @@ def _login_oauth(request, provider, authurl, tokenurl, scope, authdatafunc):
                        # handled elsewhere, so store the details we got from
                        # the oauth login in the session, and pass the user on.
                        request.session['oauth_email'] = email
-                       request.session['oauth_firstname'] = firstname
-                       request.session['oauth_lastname'] = lastname
+                       request.session['oauth_firstname'] = firstname or ''
+                       request.session['oauth_lastname'] = lastname or ''
                        return HttpResponseRedirect('/account/signup/oauth/')
 
                log.info("Oauth signin of {0} using {1} from {2}.".format(email, provider, get_client_ip(request)))