@hedhog/admin 0.46.3 → 0.46.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"auth.guard.d.ts","sourceRoot":"","sources":["../../../src/auth/guards/auth.guard.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,gBAAgB,EAGjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,qBACa,SAAU,YAAW,WAAW;IAEzC,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,SAAS;gBADT,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,SAAS;IAGxB,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IA8B9D,OAAO,CAAC,sBAAsB;CAK/B"}
1
+ {"version":3,"file":"auth.guard.d.ts","sourceRoot":"","sources":["../../../src/auth/guards/auth.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAGjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,qBACa,SAAU,YAAW,WAAW;IAEzC,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,SAAS;gBADT,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,SAAS;IAGxB,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IA0B9D,OAAO,CAAC,sBAAsB;CAK/B"}
@@ -10,41 +10,34 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AuthGuard = void 0;
13
- const core_1 = require("@hedhog/core");
14
13
  const common_1 = require("@nestjs/common");
15
- const core_2 = require("@nestjs/core");
14
+ const core_1 = require("@nestjs/core");
16
15
  const auth_service_1 = require("../auth.service");
16
+ const core_2 = require("@hedhog/core");
17
17
  let AuthGuard = class AuthGuard {
18
18
  constructor(auth, reflector) {
19
19
  this.auth = auth;
20
20
  this.reflector = reflector;
21
21
  }
22
22
  async canActivate(context) {
23
- const isPublic = this.reflector.getAllAndOverride(core_1.IS_PUBLIC_KEY, [
23
+ const isPublic = this.reflector.getAllAndOverride(core_2.IS_PUBLIC_KEY, [
24
24
  context.getHandler(),
25
25
  context.getClass(),
26
26
  ]);
27
+ if (isPublic) {
28
+ return true;
29
+ }
27
30
  const request = context.switchToHttp().getRequest();
28
31
  const token = this.extractTokenFromHeader(request);
29
32
  if (!token) {
30
- if (isPublic) {
31
- return true;
32
- }
33
- else {
34
- throw new common_1.UnauthorizedException();
35
- }
33
+ throw new common_1.UnauthorizedException();
36
34
  }
37
35
  try {
38
36
  const payload = await this.auth.verifyToken(token);
39
37
  request['auth'] = payload;
40
38
  }
41
39
  catch (error) {
42
- if (isPublic) {
43
- return true;
44
- }
45
- else {
46
- throw new common_1.UnauthorizedException(error);
47
- }
40
+ throw new common_1.UnauthorizedException(error);
48
41
  }
49
42
  return true;
50
43
  }
@@ -58,6 +51,6 @@ exports.AuthGuard = AuthGuard;
58
51
  exports.AuthGuard = AuthGuard = __decorate([
59
52
  (0, common_1.Injectable)(),
60
53
  __metadata("design:paramtypes", [auth_service_1.AuthService,
61
- core_2.Reflector])
54
+ core_1.Reflector])
62
55
  ], AuthGuard);
63
56
  //# sourceMappingURL=auth.guard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../../../src/auth/guards/auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAA6C;AAC7C,2CAKwB;AACxB,uCAAyC;AAEzC,kDAA8C;AAGvC,IAAM,SAAS,GAAf,MAAM,SAAS;IACpB,YACU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AAgB;;QAC7C,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,MAAA,MAAA,OAAO,CAAC,OAAO,CAAC,aAAa,0CAAE,KAAK,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC;QAEtE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/C,CAAC;CACF,CAAA;AArCY,8BAAS;oBAAT,SAAS;IADrB,IAAA,mBAAU,GAAE;qCAGK,0BAAW;QACN,gBAAS;GAHnB,SAAS,CAqCrB"}
@@ -44,30 +44,30 @@ export declare class MenuController {
44
44
  created_at: Date;
45
45
  updated_at: Date;
46
46
  slug: string;
47
+ icon: string | null;
47
48
  menu_id: number | null;
48
49
  url: string | null;
49
50
  order: number;
50
- icon: string | null;
51
51
  }>;
52
52
  create(data: CreateDTO): Promise<{
53
53
  id: number;
54
54
  created_at: Date;
55
55
  updated_at: Date;
56
56
  slug: string;
57
+ icon: string | null;
57
58
  menu_id: number | null;
58
59
  url: string | null;
59
60
  order: number;
60
- icon: string | null;
61
61
  }>;
62
62
  update(menuId: number, data: UpdateDTO): Promise<{
63
63
  id: number;
64
64
  created_at: Date;
65
65
  updated_at: Date;
66
66
  slug: string;
67
+ icon: string | null;
67
68
  menu_id: number | null;
68
69
  url: string | null;
69
70
  order: number;
70
- icon: string | null;
71
71
  }>;
72
72
  delete(data: DeleteDTO): Promise<import(".prisma/client").Prisma.BatchPayload>;
73
73
  updateOrder(data: OrderDTO): Promise<void>;
@@ -45,20 +45,20 @@ export declare class MenuService {
45
45
  created_at: Date;
46
46
  updated_at: Date;
47
47
  slug: string;
48
+ icon: string | null;
48
49
  menu_id: number | null;
49
50
  url: string | null;
50
51
  order: number;
51
- icon: string | null;
52
52
  }>;
53
53
  create({ slug, url, icon, order, menuId }: CreateDTO): Promise<{
54
54
  id: number;
55
55
  created_at: Date;
56
56
  updated_at: Date;
57
57
  slug: string;
58
+ icon: string | null;
58
59
  menu_id: number | null;
59
60
  url: string | null;
60
61
  order: number;
61
- icon: string | null;
62
62
  }>;
63
63
  update({ id, data }: {
64
64
  id: number;
@@ -68,10 +68,10 @@ export declare class MenuService {
68
68
  created_at: Date;
69
69
  updated_at: Date;
70
70
  slug: string;
71
+ icon: string | null;
71
72
  menu_id: number | null;
72
73
  url: string | null;
73
74
  order: number;
74
- icon: string | null;
75
75
  }>;
76
76
  delete({ ids }: DeleteDTO): Promise<import(".prisma/client").Prisma.BatchPayload>;
77
77
  updateOrder({ ids }: OrderDTO): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hedhog/admin",
3
- "version": "0.46.3",
3
+ "version": "0.46.4",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,4 +1,3 @@
1
- import { IS_PUBLIC_KEY } from '@hedhog/core';
2
1
  import {
3
2
  CanActivate,
4
3
  ExecutionContext,
@@ -8,6 +7,7 @@ import {
8
7
  import { Reflector } from '@nestjs/core';
9
8
  import { Request } from 'express';
10
9
  import { AuthService } from '../auth.service';
10
+ import { IS_PUBLIC_KEY } from '@hedhog/core';
11
11
 
12
12
  @Injectable()
13
13
  export class AuthGuard implements CanActivate {
@@ -22,26 +22,22 @@ export class AuthGuard implements CanActivate {
22
22
  context.getClass(),
23
23
  ]);
24
24
 
25
+ if (isPublic) {
26
+ return true;
27
+ }
28
+
25
29
  const request = context.switchToHttp().getRequest();
26
30
  const token = this.extractTokenFromHeader(request);
27
31
 
28
32
  if (!token) {
29
- if (isPublic) {
30
- return true;
31
- } else {
32
- throw new UnauthorizedException();
33
- }
33
+ throw new UnauthorizedException();
34
34
  }
35
35
  try {
36
36
  const payload = await this.auth.verifyToken(token);
37
37
 
38
38
  request['auth'] = payload;
39
39
  } catch (error) {
40
- if (isPublic) {
41
- return true;
42
- } else {
43
- throw new UnauthorizedException(error);
44
- }
40
+ throw new UnauthorizedException(error);
45
41
  }
46
42
  return true;
47
43
  }