aboutsummaryrefslogtreecommitdiffstats
path: root/apps/mobile/lib/session.ts
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-04-09 19:05:28 +0100
committerMohamedBassem <me@mbassem.com>2024-04-09 19:05:28 +0100
commitf696d33b645c53369ec5833593bdc77c9fb7cea9 (patch)
treebde841a66187af0581831316a4b90895db1690a1 /apps/mobile/lib/session.ts
parent5ab6c3304b4a2d055767b8195fac9c9eec776d16 (diff)
downloadkarakeep-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.ts8
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 {