@goweekdays/layer-common 1.5.5 → 1.5.6
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/CHANGELOG.md +6 -0
- package/composables/useLocalAuth.ts +13 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -19,12 +19,24 @@ export default function useLocalAuth() {
|
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
function clearCookies() {
|
|
23
23
|
useCookie("sid", cookieConfig).value = null;
|
|
24
24
|
useCookie("user", cookieConfig).value = null;
|
|
25
25
|
useCookie("role", cookieConfig).value = null;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
async function logout() {
|
|
29
|
+
try {
|
|
30
|
+
await useNuxtApp().$api<Record<string, any>>("/api/auth/logout", {
|
|
31
|
+
method: "DELETE",
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
await clearCookies();
|
|
35
|
+
} catch (error: any) {
|
|
36
|
+
console.log(error.response._data.message || "Error logging out");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
async function getCurrentUser() {
|
|
29
41
|
const user = useCookie("user", cookieConfig).value;
|
|
30
42
|
if (!user) return null;
|