Skip to content

Commit 53d68ed

Browse files
authored
Delay promise for revoke (#195)
* adding a 1 second delay before revoking a token
1 parent 9ee4996 commit 53d68ed

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/auth/auth-api-request.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,9 @@ export class FirebaseAuthRequestHandler {
536536
* In addition to revoking all refresh tokens for a user, all ID tokens issued
537537
* before revocation will also be revoked on the Auth backend. Any request with an
538538
* ID token generated before revocation will be rejected with a token expired error.
539+
* Note that due to the fact that the timestamp is stored in seconds, any tokens minted in
540+
* the same second as the revocation will still be valid. If there is a chance that a token
541+
* was minted in the last second, delay for 1 second before revoking.
539542
*
540543
* @param {string} uid The user whose tokens are to be revoked.
541544
* @return {Promise<string>} A promise that resolves when the operation completes

test/integration/auth.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ describe('admin.auth', () => {
167167
})
168168
.then((decodedIdToken) => {
169169
// Verification should succeed. Revoke that user's session.
170-
return admin.auth().revokeRefreshTokens(decodedIdToken.sub);
170+
return new Promise((resolve) => setTimeout(() => resolve(
171+
admin.auth().revokeRefreshTokens(decodedIdToken.sub)
172+
), 1000));
171173
})
172174
.then(() => {
173175
// verifyIdToken without checking revocation should still succeed.

0 commit comments

Comments
 (0)