diff options
| author | MohamedBassem <me@mbassem.com> | 2024-04-09 19:05:28 +0100 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-04-09 19:05:28 +0100 |
| commit | f696d33b645c53369ec5833593bdc77c9fb7cea9 (patch) | |
| tree | bde841a66187af0581831316a4b90895db1690a1 /apps/mobile/lib/session.ts | |
| parent | 5ab6c3304b4a2d055767b8195fac9c9eec776d16 (diff) | |
| download | karakeep-f696d33b645c53369ec5833593bdc77c9fb7cea9.tar.zst | |
fix: Delete the API key on logout from phone or extension
Diffstat (limited to 'apps/mobile/lib/session.ts')
| -rw-r--r-- | apps/mobile/lib/session.ts | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/apps/mobile/lib/session.ts b/apps/mobile/lib/session.ts index bafb3a09..8eb646cb 100644 --- a/apps/mobile/lib/session.ts +++ b/apps/mobile/lib/session.ts @@ -1,12 +1,18 @@ import { useCallback } from "react"; import useAppSettings from "./settings"; +import { api } from "./trpc"; export function useSession() { const { settings, setSettings } = useAppSettings(); + const { mutate: deleteKey } = api.apiKeys.revoke.useMutation(); + const logout = useCallback(() => { - setSettings({ ...settings, apiKey: undefined }); + if (settings.apiKeyId) { + deleteKey({ id: settings.apiKeyId }); + } + setSettings({ ...settings, apiKey: undefined, apiKeyId: undefined }); }, [settings, setSettings]); return { |
