Skip to content

Commit e1e6b58

Browse files
committed
chore: debug
1 parent a6a0e15 commit e1e6b58

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/cmap/auth/mongodb_oidc/callback_workflow.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,11 @@ export class CallbackWorkflow implements Workflow {
8383
);
8484
let result;
8585
if (entry) {
86+
console.log('ENTRY IN THE CACHE');
8687
// Reauthentication cannot use a token from the cache since the server has
8788
// stated it is invalid by the request for reauthentication.
8889
if (entry.isValid() && !reauthenticating) {
90+
console.log('ENTRY VALID NO REAUTH');
8991
// Presence of a valid cache entry means we can skip to the finishing step.
9092
result = await this.finishAuthentication(
9193
connection,
@@ -94,6 +96,7 @@ export class CallbackWorkflow implements Workflow {
9496
response?.speculativeAuthenticate?.conversationId
9597
);
9698
} else {
99+
console.log('FETCH ACCESS TOKEN');
97100
// Presence of an expired cache entry means we must fetch a new one and
98101
// then execute the final step.
99102
const tokenResult = await this.fetchAccessToken(
@@ -105,13 +108,15 @@ export class CallbackWorkflow implements Workflow {
105108
refreshCallback
106109
);
107110
try {
111+
console.log('FINISH AUTH');
108112
result = await this.finishAuthentication(
109113
connection,
110114
credentials,
111115
tokenResult,
112116
reauthenticating ? undefined : response?.speculativeAuthenticate?.conversationId
113117
);
114118
} catch (error) {
119+
console.log('ERROR ON AUTH FINISH');
115120
// If we are reauthenticating and this errors with reauthentication
116121
// required, we need to do the entire process over again and clear
117122
// the cache entry.
@@ -133,6 +138,7 @@ export class CallbackWorkflow implements Workflow {
133138
}
134139
}
135140
} else {
141+
console.log('NO CACHE ENTRY');
136142
// No entry in the cache requires us to do all authentication steps
137143
// from start to finish, including getting a fresh token for the cache.
138144
const startDocument = await this.startAuthentication(
@@ -227,6 +233,7 @@ export class CallbackWorkflow implements Workflow {
227233
if (entry) {
228234
// If the cache entry is valid, return the token result.
229235
if (entry.isValid() && !reauthenticating) {
236+
console.log('FETCH - ENTRY VALID NO REAUTH');
230237
return entry.tokenResult;
231238
}
232239
// If the cache entry is not valid, remove it from the cache and first attempt
@@ -254,6 +261,7 @@ export class CallbackWorkflow implements Workflow {
254261
);
255262
throw new MongoMissingCredentialsError(CALLBACK_RESULT_ERROR);
256263
}
264+
console.log('DELETING EXPIRED ENTRIES');
257265
// Cleanup the cache.
258266
this.cache.deleteExpiredEntries();
259267
// Put the new entry into the cache.

0 commit comments

Comments
 (0)