@witchcraft/nuxt-auth 0.1.6 → 0.1.8
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.
- package/dist/module.json +1 -1
- package/dist/runtime/components/LoginProviderButtons.client.d.vue.ts +1 -1
- package/dist/runtime/components/LoginProviderButtons.client.vue +18 -14
- package/dist/runtime/components/LoginProviderButtons.client.vue.d.ts +1 -1
- package/dist/runtime/composables/useAuth.js +3 -2
- package/dist/runtime/core/providers/github.d.ts +1 -1
- package/dist/runtime/core/providers/google.d.ts +1 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
class="
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
3
|
+
:class="twMerge(`
|
|
4
|
+
flex-1
|
|
5
|
+
flex
|
|
6
|
+
flex-col
|
|
7
|
+
items-stretch
|
|
8
|
+
justify-center
|
|
9
|
+
gap-2
|
|
10
|
+
`, $attrs?.class)"
|
|
11
11
|
>
|
|
12
12
|
<template
|
|
13
13
|
v-for="provider in enabledProviders"
|
|
@@ -19,40 +19,44 @@
|
|
|
19
19
|
v-if="provider"
|
|
20
20
|
:id="'login-provider-' + provider"
|
|
21
21
|
type="button"
|
|
22
|
-
class="p-2
|
|
22
|
+
class="text-l p-2 px-4 [&_label]:justify-start [&_label]:gap-4"
|
|
23
23
|
:style="styles[provider]"
|
|
24
24
|
:key="provider"
|
|
25
25
|
@click="login(provider, loginOptions)"
|
|
26
26
|
>
|
|
27
27
|
<WIcon
|
|
28
28
|
v-if="styles[provider]?.logo"
|
|
29
|
-
class="
|
|
29
|
+
class="text-xl"
|
|
30
30
|
>
|
|
31
31
|
<component
|
|
32
32
|
:is="styles[provider]?.logo"
|
|
33
33
|
/>
|
|
34
34
|
</WIcon>
|
|
35
|
-
|
|
35
|
+
<div>
|
|
36
|
+
Sign in / Register with {{ styles[provider]?.name ?? provider }}
|
|
37
|
+
</div>
|
|
36
38
|
</WButton>
|
|
37
39
|
</template>
|
|
38
40
|
<slot
|
|
39
41
|
name="extra"
|
|
40
|
-
class="
|
|
41
|
-
|
|
42
|
+
icon-class="text-xl"
|
|
43
|
+
class="text-l p-2 px-4 [&_label]:justify-start [&_label]:gap-4"
|
|
42
44
|
/>
|
|
43
45
|
</div>
|
|
44
46
|
</template>
|
|
45
47
|
|
|
46
48
|
<script setup>
|
|
47
49
|
import { useInjectedDarkMode } from "@witchcraft/ui/composables/useInjectedDarkMode";
|
|
50
|
+
import { twMerge } from "@witchcraft/ui/utils/twMerge";
|
|
48
51
|
import defu from "defu";
|
|
49
52
|
import { useRuntimeConfig } from "#app";
|
|
50
|
-
import { computed } from "#imports";
|
|
53
|
+
import { computed, useAttrs } from "#imports";
|
|
51
54
|
import { useAuth } from "../composables/useAuth.js";
|
|
52
55
|
import { providerStyles as baseProviderStyles } from "../core/providerStyles.js";
|
|
53
56
|
const rc = useRuntimeConfig();
|
|
54
57
|
const config = rc.public.auth;
|
|
55
58
|
const enabledProviders = config.enabledProviders;
|
|
59
|
+
const $attrs = useAttrs();
|
|
56
60
|
const { darkMode: isDark } = useInjectedDarkMode();
|
|
57
61
|
const props = defineProps({
|
|
58
62
|
providerStyles: { type: Object, required: false, default: () => ({}) },
|
|
@@ -36,11 +36,12 @@ export const useAuth = ({ handleActions } = {}) => {
|
|
|
36
36
|
}
|
|
37
37
|
async function logout() {
|
|
38
38
|
setFetchUserOnNavigation();
|
|
39
|
-
|
|
39
|
+
const wasSemiAuthed = isSemiAuthed.value;
|
|
40
40
|
await Promise.allSettled(hooks.beforeLogout.map((listener) => listener()));
|
|
41
41
|
const handled = handleActions?.("logout", getAuthApiRoute(useRuntimeConfig().public, "logout"));
|
|
42
|
+
userData.value = null;
|
|
42
43
|
if (!handled) {
|
|
43
|
-
const res = await $fetch(getAuthApiRoute(useRuntimeConfig().public, "logout"), {
|
|
44
|
+
const res = wasSemiAuthed ? true : await $fetch(getAuthApiRoute(useRuntimeConfig().public, "logout"), {
|
|
44
45
|
cache: "no-store",
|
|
45
46
|
method: "post"
|
|
46
47
|
});
|
|
@@ -79,7 +79,7 @@ export default class GithubProvider implements ProviderHandler<"oauth2", "github
|
|
|
79
79
|
}
|
|
80
80
|
export declare const githubProviderStyle: {
|
|
81
81
|
name: string;
|
|
82
|
-
logo: any
|
|
82
|
+
logo: import("vue").FunctionalComponent<import("vue").SVGAttributes, {}, any, {}>;
|
|
83
83
|
style: {
|
|
84
84
|
bg: string;
|
|
85
85
|
bgDark: string;
|
|
@@ -60,7 +60,7 @@ export default class GoogleProvider implements ProviderHandler<"oauth2_pcke", "g
|
|
|
60
60
|
}
|
|
61
61
|
export declare const googleProviderStyle: {
|
|
62
62
|
name: string;
|
|
63
|
-
logo: any
|
|
63
|
+
logo: import("vue").FunctionalComponent<import("vue").SVGAttributes, {}, any, {}>;
|
|
64
64
|
style: {
|
|
65
65
|
bg: string;
|
|
66
66
|
bgDark: string;
|