Repository navigation
[auth0] Fall back to email if first and last names not found - #65
Conversation
IamJeffG
left a comment
There was a problem hiding this comment.
Just want to make sure you want the email address in all 3 fields? That might look ugly.
I wonder if Superset has its own logic at display time for dealing with missing first_name, last_name, i.e. should we be setting them to empty strings instead?
| "first_name": me.get("given_name") or me["email"], | ||
| "last_name": me.get("family_name") or me["email"], |
There was a problem hiding this comment.
FYI dict.get takes an optional 2nd argument, which is the default value when not found
| "first_name": me.get("given_name") or me["email"], | |
| "last_name": me.get("family_name") or me["email"], | |
| "first_name": me.get("given_name", me["email"]), | |
| "last_name": me.get("family_name", me["email"]), |
Note that my suggested code will still resolve me["email"] no matter what (your code will not, at least not on this line). That matters because if "email" were not defined it could fail with a KeyError. (But in thsi particular file that would have already happened on line 236.)
8acf55f to
ce2825f
Compare
ce2825f to
e41217f
Compare
|
PR body now updated, and the code is ready for review. |
| "last_name": me["family_name"], | ||
| "first_name": me.get("given_name") | ||
| or "", # Auth0 will not return first (or last) name if users signed up with email and password instead of social login | ||
| "last_name": me.get("family_name") or "", |
There was a problem hiding this comment.
This, tooo, can be me.get("family_name", "") but your call!

#64 introduced a change where we pull
given_nameandfamily_namefrom auth0 instead of trying to construct these from a full name string using a space delimiter. But I didn't think of the case where a user created an auth0 account with username and password, hence nogiven_nameorfamily_namefields were set. This resulted in two users this morning reporting being unable to login to Superset.This PR fixes that by setting the fallback to an empty string, which I confirmed works in Superset (see my comment #65 (comment))