From b85c5d70fa0fa30fbd11f04709c23225bd8246f2 Mon Sep 17 00:00:00 2001 From: panteliselef Date: Mon, 25 Nov 2024 22:13:32 +0200 Subject: [PATCH] fix(clerk-js): Persist "this" when revoking a session, from UserProfile (#4653) --- .changeset/mean-apples-approve.md | 5 +++++ .../src/ui/components/UserProfile/ActiveDevicesSection.tsx | 2 +- .../components/UserProfile/__tests__/SecurityPage.test.tsx | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/mean-apples-approve.md diff --git a/.changeset/mean-apples-approve.md b/.changeset/mean-apples-approve.md new file mode 100644 index 0000000000..776b846ba5 --- /dev/null +++ b/.changeset/mean-apples-approve.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Bug fix: Being able to revoke a session from UserProfile. diff --git a/packages/clerk-js/src/ui/components/UserProfile/ActiveDevicesSection.tsx b/packages/clerk-js/src/ui/components/UserProfile/ActiveDevicesSection.tsx index 5d0f238163..d13aa8a5b3 100644 --- a/packages/clerk-js/src/ui/components/UserProfile/ActiveDevicesSection.tsx +++ b/packages/clerk-js/src/ui/components/UserProfile/ActiveDevicesSection.tsx @@ -48,7 +48,7 @@ export const ActiveDevicesSection = () => { const DeviceItem = ({ session }: { session: SessionWithActivitiesResource }) => { const isCurrent = useSession().session?.id === session.id; const status = useLoadingStatus(); - const [revokeSession] = useReverification(session.revoke); + const [revokeSession] = useReverification(session.revoke.bind(session)); const revoke = async () => { if (isCurrent || !session) { diff --git a/packages/clerk-js/src/ui/components/UserProfile/__tests__/SecurityPage.test.tsx b/packages/clerk-js/src/ui/components/UserProfile/__tests__/SecurityPage.test.tsx index f4c8ed948b..384ef6f22b 100644 --- a/packages/clerk-js/src/ui/components/UserProfile/__tests__/SecurityPage.test.tsx +++ b/packages/clerk-js/src/ui/components/UserProfile/__tests__/SecurityPage.test.tsx @@ -113,6 +113,7 @@ describe('SecurityPage', () => { isMobile: false, }, actor: null, + revoke: jest.fn().mockResolvedValue({}), } as any as SessionWithActivitiesResource, { pathRoot: '/me/sessions', @@ -131,6 +132,7 @@ describe('SecurityPage', () => { isMobile: false, }, actor: null, + revoke: jest.fn().mockResolvedValue({}), } as any as SessionWithActivitiesResource, ]), );