@goweekdays/core 2.11.7 → 2.11.9
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 +11 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -14
- 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,19 @@ function useAuthService() {
|
|
|
634
633
|
if (!isPasswordValid) {
|
|
635
634
|
throw new import_utils2.BadRequestError("Invalid password");
|
|
636
635
|
}
|
|
636
|
+
const { setCache } = (0, import_utils2.useCache)(`user:${_user._id?.toString()}`);
|
|
637
637
|
const sid = v4_default();
|
|
638
638
|
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
|
-
});
|
|
639
|
+
await setCache(cacheKey, _user, 14400);
|
|
644
640
|
return { sid, user: _user._id?.toString() ?? "" };
|
|
645
641
|
}
|
|
646
|
-
async function logout(
|
|
642
|
+
async function logout(user) {
|
|
643
|
+
const { delNamespace } = (0, import_utils2.useCache)(`user:${user}`);
|
|
647
644
|
try {
|
|
648
|
-
await
|
|
645
|
+
await delNamespace();
|
|
649
646
|
return "Session deleted successfully";
|
|
650
647
|
} catch (error) {
|
|
651
|
-
throw new import_utils2.InternalServerError("
|
|
648
|
+
throw new import_utils2.InternalServerError("Failed to delete session");
|
|
652
649
|
}
|
|
653
650
|
}
|
|
654
651
|
return {
|
|
@@ -8597,7 +8594,7 @@ function useSubscriptionService() {
|
|
|
8597
8594
|
throw new import_utils44.BadRequestError("User is not a member of the organization.");
|
|
8598
8595
|
}
|
|
8599
8596
|
const nextBillingDate = /* @__PURE__ */ new Date();
|
|
8600
|
-
nextBillingDate.
|
|
8597
|
+
nextBillingDate.setDate(nextBillingDate.getDate() + 30);
|
|
8601
8598
|
const { subscriptionAmount, currency } = await computeFee({
|
|
8602
8599
|
seats: value.seats,
|
|
8603
8600
|
promoCode: value.promoCode,
|
|
@@ -11176,13 +11173,13 @@ function useAuthController() {
|
|
|
11176
11173
|
}
|
|
11177
11174
|
}
|
|
11178
11175
|
async function logout(req, res, next) {
|
|
11179
|
-
const
|
|
11180
|
-
if (!
|
|
11181
|
-
next(new import_utils54.BadRequestError("
|
|
11176
|
+
const user = req.headers["user"] ?? "";
|
|
11177
|
+
if (!user) {
|
|
11178
|
+
next(new import_utils54.BadRequestError("Failed to identify user from request."));
|
|
11182
11179
|
return;
|
|
11183
11180
|
}
|
|
11184
11181
|
try {
|
|
11185
|
-
await useAuthService().logout(
|
|
11182
|
+
await useAuthService().logout(user);
|
|
11186
11183
|
res.json({ message: "Logged out successfully" });
|
|
11187
11184
|
} catch (error) {
|
|
11188
11185
|
if (error instanceof import_utils54.AppError) {
|