Skip to content

Commit

Permalink
Invalidate cache on key update
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucieo committed Sep 22, 2023
1 parent 8740745 commit c8111ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/actions/generate-api-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import db from '@/lib/db';
import * as Sentry from '@sentry/nextjs';
import jwt from 'jsonwebtoken';
import { revalidateTag } from 'next/cache';

interface APIKeyGenerationResult {
error?: {
Expand Down Expand Up @@ -36,6 +37,7 @@ export default async function generateAPIKey(
apiKey: token,
},
});
revalidateTag('check-user-team-by-slug');

return {
data: {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export const checkUserTeamBySlug = unstable_cache(
include: { user: { select: { email: true } } },
},
},
})
}),
['checkUserTeamBySlug'],
{ tags: ['check-user-team-by-slug'] }
);

export const checkDigestAuth = (teamId: string, digestId: string) =>
Expand Down

0 comments on commit c8111ce

Please sign in to comment.