Skip to content

Commit 5d25027

Browse files
authored
fix(backend): Rename password compromised action and introduces unsetting a compromised password (#7477)
1 parent 54cd476 commit 5d25027

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export type UserService = {
7676
createFakeOrganization: (userId: string) => Promise<FakeOrganization>;
7777
getUser: (opts: { id?: string; email?: string }) => Promise<User | undefined>;
7878
createFakeAPIKey: (userId: string) => Promise<FakeAPIKey>;
79-
passwordCompromised: (userId: string) => Promise<void>;
79+
setPasswordCompromised: (userId: string) => Promise<void>;
8080
};
8181

8282
/**
@@ -212,7 +212,7 @@ export const createUserService = (clerkClient: ClerkClient) => {
212212
clerkClient.apiKeys.revoke({ apiKeyId: apiKey.id, revocationReason: reason }),
213213
} satisfies FakeAPIKey;
214214
},
215-
passwordCompromised: async (userId: string) => {
215+
setPasswordCompromised: async (userId: string) => {
216216
await clerkClient.users.__experimental_passwordCompromised(userId);
217217
},
218218
};

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

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

25-
await u.services.users.passwordCompromised(createdUser.id);
25+
await u.services.users.setPasswordCompromised(createdUser.id);
2626

2727
// Performs sign-in
2828
await u.po.signIn.goTo();
@@ -69,7 +69,7 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasksResetPassword
6969
const user = u.services.users.createFakeUser();
7070
const createdUser = await u.services.users.createBapiUser(user);
7171

72-
await u.services.users.passwordCompromised(createdUser.id);
72+
await u.services.users.setPasswordCompromised(createdUser.id);
7373
const fakeOrganization = u.services.organizations.createFakeOrganization();
7474
await u.services.organizations.createBapiOrganization({
7575
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)