From 13058f11b90299d333ce30c97977cbb7f67a99b2 Mon Sep 17 00:00:00 2001 From: David Rodrigue Date: Mon, 30 May 2022 11:33:25 -0500 Subject: [PATCH] fix handling of PNG profile pic --- src/routes/oauth2-signin.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/routes/oauth2-signin.ts b/src/routes/oauth2-signin.ts index 45352db..1eead19 100644 --- a/src/routes/oauth2-signin.ts +++ b/src/routes/oauth2-signin.ts @@ -58,12 +58,13 @@ export const addRoute = (env: RouteInitEnvironment) => { if (contentType === 'image/png') { //state.provider === 'google' && // Don't accept image/png, because it's probably a placeholder image. Google does this by creating a png with people's initials user_details.picture = []; - return; } - const image = await response.arrayBuffer(); - let buff = Buffer.from(image); - best.url = `data:${contentType};base64,${buff.toString('base64')}`; - user_details.picture = [best]; // Only keep the best one + else { + const image = await response.arrayBuffer(); + let buff = Buffer.from(image); + best.url = `data:${contentType};base64,${buff.toString('base64')}`; + user_details.picture = [best]; // Only keep the best one + } } catch(err) { env.debug.warn(`Could not fetch profile picture from "${best.url}": `, err);