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) => {
17
17
18
18
if ( token ) {
19
19
const adminApp = nuxtApp . $firebaseAdminApp as AdminApp
20
- const auth = getAdminAuth ( adminApp )
20
+ const adminAuth = getAdminAuth ( adminApp )
21
21
22
22
try {
23
23
// 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 )
26
26
} catch ( err ) {
27
27
// TODO: some errors should probably go higher
28
28
// ignore the error and consider the user as not logged in
29
29
if ( isFirebaseError ( err ) && err . code === 'auth/id-token-expired' ) {
30
+ // Other errors to be handled: auth/argument-error
30
31
// the error is fine, the user is not logged in
31
32
} else {
32
33
// 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(
29
29
const token = getGlobalScope ( firebaseApp , app ) . run ( ( ) => ref < string > ( ) ) !
30
30
app . provide ( AppCheckTokenInjectSymbol , token )
31
31
32
+ console . log ( '[VueFire]: Initializing AppCheck on the server' )
32
33
const appCheck = initializeAppCheck ( firebaseApp , {
33
34
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
37
44
. 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
+ } ,
42
55
} ) ,
43
56
isTokenAutoRefreshEnabled : false ,
44
57
} )
You can’t perform that action at this time.
0 commit comments