File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,19 +64,31 @@ async function authenticateAndCreateJWT(
6464 } ) ;
6565
6666 const body = await resp . json ( ) ;
67+ console . log ( "OAuth Response Body:" , body ) ;
6768
69+ if ( body . error ) {
70+ console . error ( "OAuth Error:" , body . error_description ) ;
71+ ctx . response . body = "not authorized" ;
72+ return ;
73+ }
74+
75+ // Pass the access token to checkUser
6876 const { status, userId } = await checkUser ( body . access_token , provider ) ;
6977
78+ console . log ( "DB Status for User:" , userId , status ) ;
79+
7080 ctx . response . headers . set ( "Access-Control-Allow-Origin" , "*" ) ;
7181
7282 if ( status . matchedCount == 1 || status . upsertedId !== undefined ) {
7383 const id_jwt = await createJWT ( provider , userId ) ;
7484 Sentry . captureMessage ( "User " + userId + " logged in" , "info" ) ;
7585 ctx . response . body = id_jwt ;
7686 } else {
87+ console . error ( "Authorization failed based on DB status" ) ;
7788 ctx . response . body = "not authorized" ;
7889 }
7990 } else {
91+ console . error ( "Code was null" ) ;
8092 ctx . response . body = "not authorized" ;
8193 }
8294}
You can’t perform that action at this time.
0 commit comments