Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/evil-points-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': patch
---

Renaming `__experimental_passwordCompromised` to `__experimental_setPasswordCompromised` and introducing `__experimental_unsetPasswordCompromised`
6 changes: 3 additions & 3 deletions integration/testUtils/usersService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export type UserService = {
createFakeOrganization: (userId: string) => Promise<FakeOrganization>;
getUser: (opts: { id?: string; email?: string }) => Promise<User | undefined>;
createFakeAPIKey: (userId: string) => Promise<FakeAPIKey>;
passwordCompromised: (userId: string) => Promise<void>;
setPasswordCompromised: (userId: string) => Promise<void>;
};

/**
Expand Down Expand Up @@ -236,8 +236,8 @@ export const createUserService = (clerkClient: ClerkClient) => {
clerkClient.apiKeys.revoke({ apiKeyId: apiKey.id, revocationReason: reason }),
} satisfies FakeAPIKey;
},
passwordCompromised: async (userId: string) => {
await withErrorLogging('passwordCompromised', () => clerkClient.users.__experimental_passwordCompromised(userId));
setPasswordCompromised: async (userId: string) => {
await clerkClient.users.__experimental_setPasswordCompromised(userId);
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasksResetPassword
const user = u.services.users.createFakeUser();
const createdUser = await u.services.users.createBapiUser(user);

await u.services.users.passwordCompromised(createdUser.id);
await u.services.users.setPasswordCompromised(createdUser.id);

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

await u.services.users.passwordCompromised(createdUser.id);
await u.services.users.setPasswordCompromised(createdUser.id);
const fakeOrganization = u.services.organizations.createFakeOrganization();
await u.services.organizations.createBapiOrganization({
name: fakeOrganization.name,
Expand Down
25 changes: 20 additions & 5 deletions packages/backend/src/api/endpoints/UserApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ type DeleteUserExternalAccountParams = {
externalAccountId: string;
};

type SetPasswordCompromisedParams = {
revokeAllSessions?: boolean;
};

type UserID = {
userId: string;
};
Expand Down Expand Up @@ -448,14 +452,25 @@ export class UserAPI extends AbstractAPI {
});
}

public async __experimental_passwordCompromised(userId: string) {
public async __experimental_setPasswordCompromised(
userId: string,
params: SetPasswordCompromisedParams = {
revokeAllSessions: false,
},
) {
this.requireId(userId);
return this.request<User>({
method: 'POST',
path: joinPaths(basePath, userId, 'password', 'set_compromised'),
bodyParams: params,
});
}

public async __experimental_unsetPasswordCompromised(userId: string) {
this.requireId(userId);
return this.request<User>({
method: 'POST',
path: joinPaths(basePath, userId, 'password_compromised'),
bodyParams: {
revokeAllSessions: false,
},
path: joinPaths(basePath, userId, 'password', 'unset_compromised'),
});
}
}