@goweekdays/layer-common 1.0.8 → 1.1.1
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 +12 -0
- package/composables/useLocal.ts +3 -0
- package/composables/useLocalAuth.ts +3 -33
- package/composables/useUtils.ts +6 -1
- package/nuxt.config.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @goweekdays/layer-common
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 294db8a: useAuth - remove unused codes
|
|
8
|
+
|
|
9
|
+
## 1.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 7e20715: Add APP and landPage variables to login redirect
|
|
14
|
+
|
|
3
15
|
## 1.0.8
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/composables/useLocal.ts
CHANGED
|
@@ -48,6 +48,8 @@ export default function useLocal() {
|
|
|
48
48
|
const pages = ref(0);
|
|
49
49
|
const pageRange = ref("");
|
|
50
50
|
|
|
51
|
+
const landingPage = useCookie("landingPage", cookieConfig);
|
|
52
|
+
|
|
51
53
|
return {
|
|
52
54
|
cookieConfig,
|
|
53
55
|
getUserFromCookie,
|
|
@@ -59,5 +61,6 @@ export default function useLocal() {
|
|
|
59
61
|
page,
|
|
60
62
|
pages,
|
|
61
63
|
pageRange,
|
|
64
|
+
landingPage,
|
|
62
65
|
};
|
|
63
66
|
}
|
|
@@ -44,38 +44,10 @@ export default function useLocalAuth() {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
function setToken({
|
|
48
|
-
refreshToken = "",
|
|
49
|
-
accessToken = "",
|
|
50
|
-
user = "",
|
|
51
|
-
org = "",
|
|
52
|
-
}) {
|
|
53
|
-
useCookie("accessToken", cookieConfig).value = accessToken;
|
|
54
|
-
useCookie("refreshToken", cookieConfig).value = refreshToken;
|
|
55
|
-
useCookie("user", cookieConfig).value = user;
|
|
56
|
-
useCookie("org", cookieConfig).value = org;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function clearCookies() {
|
|
60
|
-
useCookie("accessToken", cookieConfig).value = null;
|
|
61
|
-
useCookie("refreshToken", cookieConfig).value = null;
|
|
62
|
-
useCookie("user", cookieConfig).value = null;
|
|
63
|
-
useCookie("organization", cookieConfig).value = null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
47
|
async function logout() {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
await useNuxtApp().$api(`/api/auth/logout/${refreshToken}`, {
|
|
71
|
-
method: "DELETE",
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
clearCookies();
|
|
75
|
-
} catch (error) {
|
|
76
|
-
console.error("Logout failed:", error);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
48
|
+
useCookie("sid", cookieConfig).value = null;
|
|
49
|
+
useCookie("user", cookieConfig).value = null;
|
|
50
|
+
useCookie("role", cookieConfig).value = null;
|
|
79
51
|
}
|
|
80
52
|
|
|
81
53
|
async function getCurrentUser() {
|
|
@@ -145,9 +117,7 @@ export default function useLocalAuth() {
|
|
|
145
117
|
authenticate,
|
|
146
118
|
login,
|
|
147
119
|
logout,
|
|
148
|
-
clearCookies,
|
|
149
120
|
getCurrentUser,
|
|
150
|
-
setToken,
|
|
151
121
|
forgotPassword,
|
|
152
122
|
resetPassword,
|
|
153
123
|
currentUser,
|
package/composables/useUtils.ts
CHANGED
|
@@ -3,7 +3,7 @@ export default function useUtils() {
|
|
|
3
3
|
|
|
4
4
|
const emailRule = (v: string): true | string => {
|
|
5
5
|
const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
6
|
-
if(!v) return true;
|
|
6
|
+
if (!v) return true;
|
|
7
7
|
return regex.test(v) || "Please enter a valid email address";
|
|
8
8
|
};
|
|
9
9
|
|
|
@@ -266,6 +266,10 @@ export default function useUtils() {
|
|
|
266
266
|
return params;
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
+
function positiveNumberRule(v: number) {
|
|
270
|
+
return (v && v >= 1) || "Value must be greater or equal to 1";
|
|
271
|
+
}
|
|
272
|
+
|
|
269
273
|
return {
|
|
270
274
|
requiredRule,
|
|
271
275
|
emailRule,
|
|
@@ -291,5 +295,6 @@ export default function useUtils() {
|
|
|
291
295
|
getRouteParam,
|
|
292
296
|
replaceMatch,
|
|
293
297
|
setRouteParams,
|
|
298
|
+
positiveNumberRule,
|
|
294
299
|
};
|
|
295
300
|
}
|
package/nuxt.config.ts
CHANGED
|
@@ -15,6 +15,7 @@ export default defineNuxtConfig({
|
|
|
15
15
|
secure: true,
|
|
16
16
|
maxAge: 30 * 24 * 60 * 60,
|
|
17
17
|
},
|
|
18
|
+
APP: (process.env.APP as string) ?? "app",
|
|
18
19
|
APP_NAME: (process.env.APP_NAME as string) ?? "App",
|
|
19
20
|
APP_NAME_ROUTE: (process.env.APP_NAME_ROUTE as string) ?? "index",
|
|
20
21
|
S3_BUCKET_ENDPOINT: (process.env.S3_BUCKET_ENDPOINT as string) ?? "",
|