abckit 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,28 +5,22 @@ import { computed, watch } from "vue";
|
|
|
5
5
|
const authClient = createAuthClient({
|
|
6
6
|
plugins: [adminClient()]
|
|
7
7
|
});
|
|
8
|
-
function setSentryUser(user) {
|
|
9
|
-
const config = useRuntimeConfig();
|
|
10
|
-
if (!config.public.abckit?.sentry) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
import("@sentry/nuxt").then((Sentry) => {
|
|
14
|
-
Sentry.setUser(user);
|
|
15
|
-
}).catch(() => {
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
8
|
export function useAuth() {
|
|
19
9
|
const session = authClient.useSession();
|
|
10
|
+
const config = useRuntimeConfig();
|
|
20
11
|
const isLoading = computed(() => session.value.isPending);
|
|
21
12
|
const isAuthenticated = computed(() => !!session.value.data?.user);
|
|
22
13
|
const user = computed(() => session.value.data?.user || null);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
14
|
+
if (config.public.abckit?.sentry) {
|
|
15
|
+
watch(user, async (currentUser) => {
|
|
16
|
+
const Sentry = await import("@sentry/nuxt");
|
|
17
|
+
if (currentUser) {
|
|
18
|
+
Sentry.setUser({ id: currentUser.id });
|
|
19
|
+
} else {
|
|
20
|
+
Sentry.setUser(null);
|
|
21
|
+
}
|
|
22
|
+
}, { immediate: true });
|
|
23
|
+
}
|
|
30
24
|
function login(returnTo) {
|
|
31
25
|
const query = returnTo ? `?return_to=${encodeURIComponent(returnTo)}` : "";
|
|
32
26
|
navigateTo(`/auth/login${query}`);
|