@nathapp/nestjs-auth 1.0.0-rc.10 → 1.0.0-rc.11
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.
|
@@ -3,6 +3,7 @@ import { Reflector } from "@nestjs/core";
|
|
|
3
3
|
declare const JwtAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
4
4
|
export declare class JwtAuthGuard extends JwtAuthGuard_base {
|
|
5
5
|
private reflector;
|
|
6
|
+
private readonly logger;
|
|
6
7
|
constructor(reflector: Reflector);
|
|
7
8
|
canActivate(context: ExecutionContext): boolean | Promise<boolean> | import("rxjs").Observable<boolean>;
|
|
8
9
|
handleRequest(err: any, user: any, info: any): any;
|
|
@@ -8,6 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var JwtAuthGuard_1;
|
|
11
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
13
|
exports.JwtAuthGuard = void 0;
|
|
13
14
|
const nestjs_common_1 = require("@nathapp/nestjs-common");
|
|
@@ -16,17 +17,29 @@ const core_1 = require("@nestjs/core");
|
|
|
16
17
|
const passport_1 = require("@nestjs/passport");
|
|
17
18
|
const constant_1 = require("../constant");
|
|
18
19
|
const decorator_1 = require("../decorator");
|
|
19
|
-
let JwtAuthGuard = class JwtAuthGuard extends (0, passport_1.AuthGuard)(constant_1.JWT_STRATEGY_NAME) {
|
|
20
|
+
let JwtAuthGuard = JwtAuthGuard_1 = class JwtAuthGuard extends (0, passport_1.AuthGuard)(constant_1.JWT_STRATEGY_NAME) {
|
|
20
21
|
constructor(reflector) {
|
|
21
22
|
super();
|
|
22
23
|
this.reflector = reflector;
|
|
24
|
+
this.logger = new common_1.Logger(JwtAuthGuard_1.name);
|
|
23
25
|
}
|
|
24
26
|
canActivate(context) {
|
|
27
|
+
const handler = context.getHandler();
|
|
28
|
+
const clazz = context.getClass();
|
|
25
29
|
const isPublic = this.reflector.getAllAndOverride(decorator_1.IS_PUBLIC_KEY, [
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
handler,
|
|
31
|
+
clazz,
|
|
32
|
+
]);
|
|
33
|
+
const RefreshToken = this.reflector.getAllAndOverride(decorator_1.REFRESH_TOKEN, [
|
|
34
|
+
handler,
|
|
35
|
+
clazz,
|
|
28
36
|
]);
|
|
29
37
|
if (isPublic) {
|
|
38
|
+
this.logger.verbose(`has isPublic decorator, class: ${clazz.name}, method: ${handler.name}`);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
if (RefreshToken) {
|
|
42
|
+
this.logger.verbose(`has RefreshToken decorator, class: ${clazz.name}, method: ${handler.name}`);
|
|
30
43
|
return true;
|
|
31
44
|
}
|
|
32
45
|
return super.canActivate(context);
|
|
@@ -38,7 +51,7 @@ let JwtAuthGuard = class JwtAuthGuard extends (0, passport_1.AuthGuard)(constant
|
|
|
38
51
|
return user;
|
|
39
52
|
}
|
|
40
53
|
};
|
|
41
|
-
JwtAuthGuard = __decorate([
|
|
54
|
+
JwtAuthGuard = JwtAuthGuard_1 = __decorate([
|
|
42
55
|
(0, common_1.Injectable)(),
|
|
43
56
|
__metadata("design:paramtypes", [core_1.Reflector])
|
|
44
57
|
], JwtAuthGuard);
|