auth-backend: fall back to username and id as displayName for profiles

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-08-20 14:09:40 +02:00
parent 8e9e5fe72f
commit 5f6f33a5ed
@@ -30,8 +30,6 @@ export const makeProfileInfo = (
profile: passport.Profile,
idToken?: string,
): ProfileInfo => {
let { displayName } = profile;
let email: string | undefined = undefined;
if (profile.emails && profile.emails.length > 0) {
const [firstEmail] = profile.emails;
@@ -44,6 +42,9 @@ export const makeProfileInfo = (
picture = firstPhoto.value;
}
let displayName: string | undefined =
profile.displayName ?? profile.username ?? profile.id;
if ((!email || !picture || !displayName) && idToken) {
try {
const decoded: Record<string, string> = jwtDecoder(idToken);