mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 07:42:23 +00:00
fix(auth): the ingest and idempotency Bearer resolvers refuse a pending account
Both resolve a Bearer token outside resolveBearerToken and checked only revoked and expiry. The deletion revokes every token in its own transaction, so only a token issued in that same instant could get through, but the rule should hold everywhere a token is resolved: both now refuse an account pending deletion.
This commit is contained in:
1 parent
69c5c65376
commit
e6c709876d
4 files changed
+53
-2
No files matched your search
@@ -426,6 +426,18 @@ describe("defaultUserIdResolver (audit C-4)", () => {
|
||||
expect(await defaultUserIdResolver()).toBeNull();
|
||||
});
|
||||
|
||||
it("rejects the Bearer token of an account pending deletion", async () => {
|
||||
vi.mocked(getSession).mockResolvedValue(null);
|
||||
mockHeader("Bearer hlk_abcdef");
|
||||
vi.mocked(prisma.apiToken.findUnique).mockResolvedValue({
|
||||
userId: "u-bearer",
|
||||
revoked: false,
|
||||
expiresAt: null,
|
||||
user: { deletionRequestedAt: new Date() },
|
||||
} as never);
|
||||
expect(await defaultUserIdResolver()).toBeNull();
|
||||
});
|
||||
|
||||
it("rejects expired Bearer tokens", async () => {
|
||||
vi.mocked(getSession).mockResolvedValue(null);
|
||||
mockHeader("Bearer hlk_abcdef");
|
||||
|
||||
Reference in new issue
Block a user