File tree Expand file tree Collapse file tree 2 files changed +16
-16
lines changed
nextjs-end/src/lib/firebase
nextjs-start/src/lib/firebase Expand file tree Collapse file tree 2 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -9,5 +9,19 @@ import { firebaseConfig } from "./config";
99import { getAuth } from "firebase/auth" ;
1010
1111export async function getAuthenticatedAppForUser ( ) {
12- throw new Error ( 'not implemented' ) ;
12+ const idToken = headers ( ) . get ( "Authorization" ) ?. split ( "Bearer " ) [ 1 ] ;
13+
14+ const firebaseServerApp = initializeServerApp (
15+ firebaseConfig ,
16+ idToken
17+ ? {
18+ authIdToken : idToken ,
19+ }
20+ : { }
21+ ) ;
22+
23+ const auth = getAuth ( firebaseServerApp ) ;
24+ await auth . authStateReady ( ) ;
25+
26+ return { firebaseServerApp, currentUser : auth . currentUser } ;
1327}
Original file line number Diff line number Diff line change @@ -9,19 +9,5 @@ import { firebaseConfig } from "./config";
99import { getAuth } from "firebase/auth" ;
1010
1111export async function getAuthenticatedAppForUser ( ) {
12- const idToken = headers ( ) . get ( "Authorization" ) ?. split ( "Bearer " ) [ 1 ] ;
13- console . log ( 'firebaseConfig' , JSON . stringify ( firebaseConfig ) ) ;
14- const firebaseServerApp = initializeServerApp (
15- firebaseConfig ,
16- idToken
17- ? {
18- authIdToken : idToken ,
19- }
20- : { }
21- ) ;
22-
23- const auth = getAuth ( firebaseServerApp ) ;
24- await auth . authStateReady ( ) ;
25-
26- return { firebaseServerApp, currentUser : auth . currentUser } ;
12+ throw new Error ( 'not implemented' ) ;
2713}
You can’t perform that action at this time.
0 commit comments