[GH-ISSUE #21] Can't login with Google if you have an PNG profile picture #11

Closed
opened 2026-05-23 08:38:20 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @eugirdor on GitHub (May 29, 2022).
Original GitHub issue: https://github.com/appy-one/acebase-server/issues/21

I think the issue is in this bit of code:

9d9e22d9d0/src/routes/oauth2-signin.ts (L52-L72)

It returns early and never executes the rest of the method, so the redirect to the callbackUrl never happens.

I think it should probably use an else instead of the return:

 if (user_details.picture && user_details.picture.length > 0) { 
     // Download it, convert to base64 
     const best = user_details.picture.sort((a,b) => a.width * a.height > b.width * b.height ? -1 : 1)[0] 
     try { 
         const response = await fetch(best.url); 
         const contentType = response.headers.get('Content-Type'); 
         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 = []; 
         } 
         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); 
         user_details.picture = null; 
     } 
 } 
Originally created by @eugirdor on GitHub (May 29, 2022). Original GitHub issue: https://github.com/appy-one/acebase-server/issues/21 I think the issue is in this bit of code: https://github.com/appy-one/acebase-server/blob/9d9e22d9d0cd94a8d273c1f12fd1eb50285c8ca7/src/routes/oauth2-signin.ts#L52-L72 It returns early and never executes the rest of the method, so the redirect to the `callbackUrl` never happens. I think it should probably use an `else` instead of the `return`: ```typescript if (user_details.picture && user_details.picture.length > 0) { // Download it, convert to base64 const best = user_details.picture.sort((a,b) => a.width * a.height > b.width * b.height ? -1 : 1)[0] try { const response = await fetch(best.url); const contentType = response.headers.get('Content-Type'); 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 = []; } 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); user_details.picture = null; } } ```
gitea-mirror 2026-05-23 08:38:20 -06:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@appy-one commented on GitHub (May 30, 2022):

Good catch! This code used to be Promise/then/catch based before I refactored to async/await, so the return statement is probably a remnant of that... If you'd want to send a PR, please do! Otherwise, I'll adjust it in the code myself.

<!-- gh-comment-id:1141008130 --> @appy-one commented on GitHub (May 30, 2022): Good catch! This code used to be Promise/then/catch based before I refactored to async/await, so the return statement is probably a remnant of that... If you'd want to send a PR, please do! Otherwise, I'll adjust it in the code myself.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/acebase-server#11
No description provided.