Skip to content

Commit 7c12ada

Browse files
authored
feat(backend): Rename passwordCompromised method to setPasswordCompromised (#7492)
1 parent d1b4d4b commit 7c12ada

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

.changeset/evil-points-fly.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/backend': patch
3+
---
4+
5+
Renaming `__experimental_passwordCompromised` to `__experimental_setPasswordCompromised` and introducing `__experimental_unsetPasswordCompromised`

integration/testUtils/usersService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export type UserService = {
8989
createFakeOrganization: (userId: string) => Promise<FakeOrganization>;
9090
getUser: (opts: { id?: string; email?: string }) => Promise<User | undefined>;
9191
createFakeAPIKey: (userId: string) => Promise<FakeAPIKey>;
92-
passwordCompromised: (userId: string) => Promise<void>;
92+
setPasswordCompromised: (userId: string) => Promise<void>;
9393
};
9494

9595
/**
@@ -236,8 +236,8 @@ export const createUserService = (clerkClient: ClerkClient) => {
236236
clerkClient.apiKeys.revoke({ apiKeyId: apiKey.id, revocationReason: reason }),
237237
} satisfies FakeAPIKey;
238238
},
239-
passwordCompromised: async (userId: string) => {
240-
await withErrorLogging('passwordCompromised', () => clerkClient.users.__experimental_passwordCompromised(userId));
239+
setPasswordCompromised: async (userId: string) => {
240+
await clerkClient.users.__experimental_setPasswordCompromised(userId);
241241
},
242242
};
243243

integration/tests/session-tasks-sign-in-reset-password.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasksResetPassword
1919
const user = u.services.users.createFakeUser();
2020
const createdUser = await u.services.users.createBapiUser(user);
2121

22-
await u.services.users.passwordCompromised(createdUser.id);
22+
await u.services.users.setPasswordCompromised(createdUser.id);
2323

2424
// Performs sign-in
2525
await u.po.signIn.goTo();
@@ -66,7 +66,7 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasksResetPassword
6666
const user = u.services.users.createFakeUser();
6767
const createdUser = await u.services.users.createBapiUser(user);
6868

69-
await u.services.users.passwordCompromised(createdUser.id);
69+
await u.services.users.setPasswordCompromised(createdUser.id);
7070
const fakeOrganization = u.services.organizations.createFakeOrganization();
7171
await u.services.organizations.createBapiOrganization({
7272
name: fakeOrganization.name,

packages/backend/src/api/endpoints/UserApi.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ type DeleteUserExternalAccountParams = {
199199
externalAccountId: string;
200200
};
201201

202+
type SetPasswordCompromisedParams = {
203+
revokeAllSessions?: boolean;
204+
};
205+
202206
type UserID = {
203207
userId: string;
204208
};
@@ -448,14 +452,25 @@ export class UserAPI extends AbstractAPI {
448452
});
449453
}
450454

451-
public async __experimental_passwordCompromised(userId: string) {
455+
public async __experimental_setPasswordCompromised(
456+
userId: string,
457+
params: SetPasswordCompromisedParams = {
458+
revokeAllSessions: false,
459+
},
460+
) {
461+
this.requireId(userId);
462+
return this.request<User>({
463+
method: 'POST',
464+
path: joinPaths(basePath, userId, 'password', 'set_compromised'),
465+
bodyParams: params,
466+
});
467+
}
468+
469+
public async __experimental_unsetPasswordCompromised(userId: string) {
452470
this.requireId(userId);
453471
return this.request<User>({
454472
method: 'POST',
455-
path: joinPaths(basePath, userId, 'password_compromised'),
456-
bodyParams: {
457-
revokeAllSessions: false,
458-
},
473+
path: joinPaths(basePath, userId, 'password', 'unset_compromised'),
459474
});
460475
}
461476
}

0 commit comments

Comments
 (0)