@goweekdays/core 2.11.8 → 2.11.10
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/dist/index.d.ts +1 -1
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -602,7 +602,6 @@ var v4_default = v4;
|
|
|
602
602
|
|
|
603
603
|
// src/resources/auth/auth.service.ts
|
|
604
604
|
function useAuthService() {
|
|
605
|
-
const { setCache, delCache } = (0, import_utils2.useCache)("sessions");
|
|
606
605
|
async function login({ email, password } = {}) {
|
|
607
606
|
if (!email) {
|
|
608
607
|
throw new import_utils2.BadRequestError("Email is required");
|
|
@@ -634,21 +633,22 @@ function useAuthService() {
|
|
|
634
633
|
if (!isPasswordValid) {
|
|
635
634
|
throw new import_utils2.BadRequestError("Invalid password");
|
|
636
635
|
}
|
|
636
|
+
const { setCache, delNamespace } = (0, import_utils2.useCache)(
|
|
637
|
+
`user:${_user._id?.toString()}`
|
|
638
|
+
);
|
|
639
|
+
await delNamespace();
|
|
637
640
|
const sid = v4_default();
|
|
638
641
|
const cacheKey = `sid:${sid}`;
|
|
639
|
-
setCache(cacheKey, _user, 14400)
|
|
640
|
-
console.log("Session ID cached successfully");
|
|
641
|
-
}).catch((error) => {
|
|
642
|
-
console.error("Error caching session ID:", error);
|
|
643
|
-
});
|
|
642
|
+
await setCache(cacheKey, _user, 14400);
|
|
644
643
|
return { sid, user: _user._id?.toString() ?? "" };
|
|
645
644
|
}
|
|
646
|
-
async function logout(
|
|
645
|
+
async function logout(user) {
|
|
646
|
+
const { delNamespace } = (0, import_utils2.useCache)(`user:${user}`);
|
|
647
647
|
try {
|
|
648
|
-
await
|
|
648
|
+
await delNamespace();
|
|
649
649
|
return "Session deleted successfully";
|
|
650
650
|
} catch (error) {
|
|
651
|
-
throw new import_utils2.InternalServerError("
|
|
651
|
+
throw new import_utils2.InternalServerError("Failed to delete session");
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
654
|
return {
|
|
@@ -11176,13 +11176,13 @@ function useAuthController() {
|
|
|
11176
11176
|
}
|
|
11177
11177
|
}
|
|
11178
11178
|
async function logout(req, res, next) {
|
|
11179
|
-
const
|
|
11180
|
-
if (!
|
|
11181
|
-
next(new import_utils54.BadRequestError("
|
|
11179
|
+
const user = req.cookies.user;
|
|
11180
|
+
if (!user) {
|
|
11181
|
+
next(new import_utils54.BadRequestError("Failed to identify user from request."));
|
|
11182
11182
|
return;
|
|
11183
11183
|
}
|
|
11184
11184
|
try {
|
|
11185
|
-
await useAuthService().logout(
|
|
11185
|
+
await useAuthService().logout(user);
|
|
11186
11186
|
res.json({ message: "Logged out successfully" });
|
|
11187
11187
|
} catch (error) {
|
|
11188
11188
|
if (error instanceof import_utils54.AppError) {
|