Skip to content

Commit 7c8ec36

Browse files
committed
Throw error for failed PAT revokes instead of silent failure
1 parent bfd8a2c commit 7c8ec36

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

apps/webapp/app/services/personalAccessToken.server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export async function getPersonalAccessTokenFromAuthorizationCode(authorizationC
8080
}
8181

8282
export async function revokePersonalAccessToken(tokenId: string, userId: string) {
83-
await prisma.personalAccessToken.update({
83+
const result = await prisma.personalAccessToken.updateMany({
8484
where: {
8585
id: tokenId,
8686
userId,
@@ -89,6 +89,10 @@ export async function revokePersonalAccessToken(tokenId: string, userId: string)
8989
revokedAt: new Date(),
9090
},
9191
});
92+
93+
if (result.count === 0) {
94+
throw new Error("PAT not found or already revoked");
95+
}
9296
}
9397

9498
export type PersonalAccessTokenAuthenticationResult = {

0 commit comments

Comments
 (0)