File tree Expand file tree Collapse file tree 2 files changed +24
-10
lines changed
packages/nuxt/src/runtime/admin Expand file tree Collapse file tree 2 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -17,16 +17,17 @@ export default defineNuxtPlugin(async (nuxtApp) => {
1717
1818 if ( token ) {
1919 const adminApp = nuxtApp . $firebaseAdminApp as AdminApp
20- const auth = getAdminAuth ( adminApp )
20+ const adminAuth = getAdminAuth ( adminApp )
2121
2222 try {
2323 // TODO: should we check for the revoked status of the token here?
24- const decodedToken = await auth . verifyIdToken ( token )
25- user = await auth . getUser ( decodedToken . uid )
24+ const decodedToken = await adminAuth . verifyIdToken ( token )
25+ user = await adminAuth . getUser ( decodedToken . uid )
2626 } catch ( err ) {
2727 // TODO: some errors should probably go higher
2828 // ignore the error and consider the user as not logged in
2929 if ( isFirebaseError ( err ) && err . code === 'auth/id-token-expired' ) {
30+ // Other errors to be handled: auth/argument-error
3031 // the error is fine, the user is not logged in
3132 } else {
3233 // ignore the error and consider the user as not logged in
Original file line number Diff line number Diff line change @@ -29,16 +29,29 @@ export function VueFireAppCheckServer(
2929 const token = getGlobalScope ( firebaseApp , app ) . run ( ( ) => ref < string > ( ) ) !
3030 app . provide ( AppCheckTokenInjectSymbol , token )
3131
32+ console . log ( '[VueFire]: Initializing AppCheck on the server' )
3233 const appCheck = initializeAppCheck ( firebaseApp , {
3334 provider : new CustomProvider ( {
34- getToken : ( ) =>
35- getAdminAppCheck ( adminApp )
36- // NOTE: appId is checked on the module
35+ getToken : ( ) => {
36+ console . log ( '[VueFire]: Getting Admin AppCheck' )
37+ const adminAppCheck = getAdminAppCheck ( adminApp )
38+ // NOTE: appId is checked on the module
39+ console . log (
40+ `[VueFire]: Getting creating token for app ${ firebaseApp . options
41+ . appId ! } .`
42+ )
43+ return adminAppCheck
3744 . createToken ( firebaseApp . options . appId ! , { ttlMillis } )
38- . then ( ( { token, ttlMillis : expireTimeMillis } ) => ( {
39- token,
40- expireTimeMillis,
41- } ) ) ,
45+ . then ( ( { token, ttlMillis : expireTimeMillis } ) => {
46+ console . log (
47+ `[VueFire]: Got AppCheck token from the server: ${ token } `
48+ )
49+ return {
50+ token,
51+ expireTimeMillis,
52+ }
53+ } )
54+ } ,
4255 } ) ,
4356 isTokenAutoRefreshEnabled : false ,
4457 } )
You can’t perform that action at this time.
0 commit comments