@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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @goweekdays/layer-common
2
2
 
3
+ ## 1.5.6
4
+
5
+ ### Patch Changes
6
+
7
+ - ad670f0: Refactor logout to call API and clear cookies
8
+
3
9
  ## 1.5.5
4
10
 
5
11
  ### Patch Changes
@@ -19,12 +19,24 @@ export default function useLocalAuth() {
19
19
  });
20
20
  }
21
21
 
22
- async function logout() {
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;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@goweekdays/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "1.5.5",
5
+ "version": "1.5.6",
6
6
  "main": "./nuxt.config.ts",
7
7
  "publishConfig": {
8
8
  "access": "public"