@zola_do/authorization 0.1.13 → 0.1.18

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.
Files changed (2) hide show
  1. package/README.md +29 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -28,6 +28,35 @@ export class AppModule {}
28
28
 
29
29
  By default, `JwtGuard` is registered as a global guard. Protect routes automatically; use `@AllowAnonymous()` for public routes.
30
30
 
31
+ ### Override JwtGuard In AppModule
32
+
33
+ If your app uses a different token payload shape or custom validation logic, override `JwtGuard` in `AppModule`.
34
+
35
+ ```typescript
36
+ import { Injectable, ExecutionContext } from '@nestjs/common';
37
+ import { JwtGuard } from '@zola_do/authorization';
38
+
39
+ @Injectable()
40
+ export class AppJwtGuard extends JwtGuard {
41
+ async canActivate(context: ExecutionContext): Promise<boolean> {
42
+ // Add app-specific token parsing/validation logic here.
43
+ return super.canActivate(context);
44
+ }
45
+ }
46
+ ```
47
+
48
+ ```typescript
49
+ import { Module } from '@nestjs/common';
50
+ import { AuthorizationModule, JwtGuard } from '@zola_do/authorization';
51
+ import { AppJwtGuard } from './guards/app-jwt.guard';
52
+
53
+ @Module({
54
+ imports: [AuthorizationModule],
55
+ providers: [{ provide: JwtGuard, useClass: AppJwtGuard }],
56
+ })
57
+ export class AppModule {}
58
+ ```
59
+
31
60
  ### Protected Routes
32
61
 
33
62
  ```typescript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zola_do/authorization",
3
- "version": "0.1.13",
3
+ "version": "0.1.18",
4
4
  "description": "JWT auth, guards, strategies for NestJS",
5
5
  "author": "zolaDO",
6
6
  "license": "ISC",