@saihu/common 1.1.5 → 1.1.7
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/auth-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAIjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"auth-guard.d.ts","sourceRoot":"","sources":["../../src/auth/auth-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAIjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,qBACa,SAAU,YAAW,WAAW;IAEzC,OAAO,CAAC,UAAU;IACI,OAAO,CAAC,QAAQ,CAAC,SAAS;IAChD,OAAO,CAAC,SAAS;gBAFT,UAAU,EAAE,UAAU,EACS,SAAS,EAAE,MAAM,EAChD,SAAS,EAAE,SAAS;IAGxB,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IA4B9D,OAAO,CAAC,sBAAsB;CAI/B"}
|
package/dist/auth/auth-guard.js
CHANGED
|
@@ -17,6 +17,7 @@ const common_1 = require("@nestjs/common");
|
|
|
17
17
|
const jwt_1 = require("@nestjs/jwt");
|
|
18
18
|
const core_1 = require("@nestjs/core");
|
|
19
19
|
const decorators_1 = require("./decorators");
|
|
20
|
+
const dto_1 = require("../dto");
|
|
20
21
|
let AuthGuard = class AuthGuard {
|
|
21
22
|
constructor(jwtService, jwtSecret, reflector) {
|
|
22
23
|
this.jwtService = jwtService;
|
|
@@ -35,7 +36,7 @@ let AuthGuard = class AuthGuard {
|
|
|
35
36
|
const request = context.switchToHttp().getRequest();
|
|
36
37
|
const token = this.extractTokenFromHeader(request);
|
|
37
38
|
if (!token) {
|
|
38
|
-
throw new
|
|
39
|
+
throw new dto_1.BaseError(dto_1.BaseResponseDto.CODE_NOT_FOUND, '令牌缺失');
|
|
39
40
|
}
|
|
40
41
|
try {
|
|
41
42
|
const payload = await this.jwtService.verifyAsync(token, {
|
|
@@ -46,7 +47,7 @@ let AuthGuard = class AuthGuard {
|
|
|
46
47
|
request.user = payload;
|
|
47
48
|
}
|
|
48
49
|
catch (_a) {
|
|
49
|
-
throw new
|
|
50
|
+
throw new dto_1.BaseError(dto_1.BaseResponseDto.CODE_UNAUTHORIZED, '令牌无效');
|
|
50
51
|
}
|
|
51
52
|
return true;
|
|
52
53
|
}
|
package/dist/auth/index.d.ts
CHANGED
package/dist/auth/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC"}
|
package/dist/auth/index.js
CHANGED