@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/dist/index.mjs
CHANGED
|
@@ -435,7 +435,6 @@ var v4_default = v4;
|
|
|
435
435
|
|
|
436
436
|
// src/resources/auth/auth.service.ts
|
|
437
437
|
function useAuthService() {
|
|
438
|
-
const { setCache, delCache } = useCache2("sessions");
|
|
439
438
|
async function login({ email, password } = {}) {
|
|
440
439
|
if (!email) {
|
|
441
440
|
throw new BadRequestError2("Email is required");
|
|
@@ -467,21 +466,19 @@ function useAuthService() {
|
|
|
467
466
|
if (!isPasswordValid) {
|
|
468
467
|
throw new BadRequestError2("Invalid password");
|
|
469
468
|
}
|
|
469
|
+
const { setCache } = useCache2(`user:${_user._id?.toString()}`);
|
|
470
470
|
const sid = v4_default();
|
|
471
471
|
const cacheKey = `sid:${sid}`;
|
|
472
|
-
setCache(cacheKey, _user, 14400)
|
|
473
|
-
console.log("Session ID cached successfully");
|
|
474
|
-
}).catch((error) => {
|
|
475
|
-
console.error("Error caching session ID:", error);
|
|
476
|
-
});
|
|
472
|
+
await setCache(cacheKey, _user, 14400);
|
|
477
473
|
return { sid, user: _user._id?.toString() ?? "" };
|
|
478
474
|
}
|
|
479
|
-
async function logout(
|
|
475
|
+
async function logout(user) {
|
|
476
|
+
const { delNamespace } = useCache2(`user:${user}`);
|
|
480
477
|
try {
|
|
481
|
-
await
|
|
478
|
+
await delNamespace();
|
|
482
479
|
return "Session deleted successfully";
|
|
483
480
|
} catch (error) {
|
|
484
|
-
throw new InternalServerError2("
|
|
481
|
+
throw new InternalServerError2("Failed to delete session");
|
|
485
482
|
}
|
|
486
483
|
}
|
|
487
484
|
return {
|
|
@@ -8616,7 +8613,7 @@ function useSubscriptionService() {
|
|
|
8616
8613
|
throw new BadRequestError41("User is not a member of the organization.");
|
|
8617
8614
|
}
|
|
8618
8615
|
const nextBillingDate = /* @__PURE__ */ new Date();
|
|
8619
|
-
nextBillingDate.
|
|
8616
|
+
nextBillingDate.setDate(nextBillingDate.getDate() + 30);
|
|
8620
8617
|
const { subscriptionAmount, currency } = await computeFee({
|
|
8621
8618
|
seats: value.seats,
|
|
8622
8619
|
promoCode: value.promoCode,
|
|
@@ -11203,13 +11200,13 @@ function useAuthController() {
|
|
|
11203
11200
|
}
|
|
11204
11201
|
}
|
|
11205
11202
|
async function logout(req, res, next) {
|
|
11206
|
-
const
|
|
11207
|
-
if (!
|
|
11208
|
-
next(new BadRequestError50("
|
|
11203
|
+
const user = req.headers["user"] ?? "";
|
|
11204
|
+
if (!user) {
|
|
11205
|
+
next(new BadRequestError50("Failed to identify user from request."));
|
|
11209
11206
|
return;
|
|
11210
11207
|
}
|
|
11211
11208
|
try {
|
|
11212
|
-
await useAuthService().logout(
|
|
11209
|
+
await useAuthService().logout(user);
|
|
11213
11210
|
res.json({ message: "Logged out successfully" });
|
|
11214
11211
|
} catch (error) {
|
|
11215
11212
|
if (error instanceof AppError25) {
|