@tabletennisshop/common 1.0.48 → 1.0.49

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/build/index.d.ts CHANGED
@@ -19,7 +19,7 @@ export * from './models/inventory.model';
19
19
  export * from './models/status-timestamp.schema';
20
20
  export * from './models/vendor.model';
21
21
  export * from './models/vendor-purchased.model';
22
- export * from './services/password';
22
+ export * from './helper/password';
23
23
  export * from './enums/product-type.enum';
24
24
  export * from './enums/order-status.enum';
25
25
  export * from './enums/payment-method.enum';
package/build/index.js CHANGED
@@ -35,7 +35,7 @@ __exportStar(require("./models/inventory.model"), exports);
35
35
  __exportStar(require("./models/status-timestamp.schema"), exports);
36
36
  __exportStar(require("./models/vendor.model"), exports);
37
37
  __exportStar(require("./models/vendor-purchased.model"), exports);
38
- __exportStar(require("./services/password"), exports);
38
+ __exportStar(require("./helper/password"), exports);
39
39
  __exportStar(require("./enums/product-type.enum"), exports);
40
40
  __exportStar(require("./enums/order-status.enum"), exports);
41
41
  __exportStar(require("./enums/payment-method.enum"), exports);
@@ -16,6 +16,7 @@ exports.CheckAuthorizedMiddleware = void 0;
16
16
  const axios_1 = __importDefault(require("axios"));
17
17
  const not_authorized_error_1 = require("../errors/not-authorized-error");
18
18
  const CheckAuthorizedMiddleware = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
19
+ //This can be wrong
19
20
  const axiosRes = yield axios_1.default.get("localhost:3000/api/users/current-user");
20
21
  if (axiosRes.status != 200) {
21
22
  throw new not_authorized_error_1.NotAuthorizedError("Not Authorized");
@@ -1,6 +1,6 @@
1
1
  import { Request, Response, NextFunction } from "express";
2
2
  interface UserPayload {
3
- id?: string;
3
+ username: string;
4
4
  email: string;
5
5
  }
6
6
  declare global {
@@ -11,7 +11,9 @@ const CurrentUserMiddleware = (req, res, next) => {
11
11
  next();
12
12
  }
13
13
  /*
14
- Try to verify jwt to {id: "", email: ""}
14
+ When a user logs in, a JWT is created and stored "id" and "email" in the session.
15
+ So to verify the user, we need to decode the JWT.
16
+ This code try to verify and decode jwt to {id: "", email: ""}
15
17
  and save it into req.currentUser.
16
18
  Finally req.currentUser back to client.
17
19
  */
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.UserModel = void 0;
13
13
  const mongoose_1 = require("mongoose");
14
- const password_1 = require("../services/password");
14
+ const password_1 = require("../helper/password");
15
15
  const user_enum_1 = require("../enums/user.enum");
16
16
  const address_schema_1 = require("./address.schema");
17
17
  const user_status_enum_1 = require("../enums/user-status.enum");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tabletennisshop/common",
3
- "version": "1.0.48",
3
+ "version": "1.0.49",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
File without changes
File without changes