rez_core 2.0.10 → 2.0.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.
- package/dist/module/auth/strategies/jwt.strategy.d.ts +2 -4
- package/dist/module/auth/strategies/jwt.strategy.js +4 -15
- package/dist/module/auth/strategies/jwt.strategy.js.map +1 -1
- package/dist/module/user/service/user-session.service.js +6 -1
- package/dist/module/user/service/user-session.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/auth/strategies/jwt.strategy.ts +14 -14
- package/src/module/user/service/user-session.service.ts +6 -1
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { UserSession } from 'src/module/user/entity/user-session.entity';
|
|
2
|
-
import { Repository } from 'typeorm';
|
|
3
1
|
import { ConfigService } from '@nestjs/config';
|
|
4
2
|
declare const JwtStrategy_base: new (...args: any) => any;
|
|
5
3
|
export declare class JwtStrategy extends JwtStrategy_base {
|
|
6
|
-
private userSessionRepository;
|
|
7
4
|
private configService;
|
|
8
|
-
constructor(
|
|
5
|
+
constructor(configService: ConfigService);
|
|
9
6
|
validate(payload: any): Promise<{
|
|
10
7
|
userId: any;
|
|
11
8
|
sessionToken: any;
|
|
12
9
|
appcode: any;
|
|
10
|
+
email_id: any;
|
|
13
11
|
}>;
|
|
14
12
|
}
|
|
15
13
|
export {};
|
|
@@ -18,36 +18,25 @@ const passport_1 = require("@nestjs/passport");
|
|
|
18
18
|
const common_1 = require("@nestjs/common");
|
|
19
19
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
20
20
|
const user_session_entity_1 = require("../../user/entity/user-session.entity");
|
|
21
|
-
const typeorm_2 = require("typeorm");
|
|
22
21
|
const config_1 = require("@nestjs/config");
|
|
23
22
|
let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
|
|
24
|
-
constructor(
|
|
23
|
+
constructor(configService) {
|
|
25
24
|
super({
|
|
26
25
|
jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
27
26
|
ignoreExpiration: false,
|
|
28
27
|
secretOrKey: configService.get('SECRET_KEY'),
|
|
29
28
|
});
|
|
30
|
-
this.userSessionRepository = userSessionRepository;
|
|
31
29
|
this.configService = configService;
|
|
32
30
|
}
|
|
33
31
|
async validate(payload) {
|
|
34
|
-
const { userId, sessionToken, appcode } = payload;
|
|
35
|
-
|
|
36
|
-
where: { session_key: sessionToken },
|
|
37
|
-
});
|
|
38
|
-
if (!userSession ||
|
|
39
|
-
userSession.is_session_loggedout ||
|
|
40
|
-
new Date(userSession.expiry_date) < new Date()) {
|
|
41
|
-
throw new common_1.UnauthorizedException('Invalid or expired session');
|
|
42
|
-
}
|
|
43
|
-
return { userId, sessionToken, appcode };
|
|
32
|
+
const { userId, sessionToken, appcode, email_id } = payload;
|
|
33
|
+
return { userId, sessionToken, appcode, email_id };
|
|
44
34
|
}
|
|
45
35
|
};
|
|
46
36
|
exports.JwtStrategy = JwtStrategy;
|
|
47
37
|
exports.JwtStrategy = JwtStrategy = __decorate([
|
|
48
38
|
(0, common_1.Injectable)(),
|
|
49
39
|
__param(0, (0, typeorm_1.InjectRepository)(user_session_entity_1.UserSession)),
|
|
50
|
-
__metadata("design:paramtypes", [
|
|
51
|
-
config_1.ConfigService])
|
|
40
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
52
41
|
], JwtStrategy);
|
|
53
42
|
//# sourceMappingURL=jwt.strategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.strategy.js","sourceRoot":"","sources":["../../../../src/module/auth/strategies/jwt.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAoD;AACpD,+CAAoD;AACpD,2CAAmE;AAEnE,6CAAmD;AACnD,+EAAyE;
|
|
1
|
+
{"version":3,"file":"jwt.strategy.js","sourceRoot":"","sources":["../../../../src/module/auth/strategies/jwt.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAoD;AACpD,+CAAoD;AACpD,2CAAmE;AAEnE,6CAAmD;AACnD,+EAAyE;AAEzE,2CAA+C;AAGxC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,IAAA,2BAAgB,EAAC,uBAAQ,CAAC;IACzD,YAGU,aAA4B;QAEpC,KAAK,CAAC;YACJ,cAAc,EAAE,yBAAU,CAAC,2BAA2B,EAAE;YACxD,gBAAgB,EAAE,KAAK;YACvB,WAAW,EAAE,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC;SAC7C,CAAC,CAAC;QANK,kBAAa,GAAb,aAAa,CAAe;IAOtC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAO;QACpB,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAe5D,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IACrD,CAAC;CACF,CAAA;AA/BY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,iCAAW,CAAC,CAAA;qCAEP,sBAAa;GAJ3B,WAAW,CA+BvB"}
|
|
@@ -33,7 +33,12 @@ let UserSessionService = class UserSessionService {
|
|
|
33
33
|
const expiryTokenInHours = this.configService.get('TOKEN_EXPIRY') || 1;
|
|
34
34
|
userSession.expiry_date = new Date(Date.now() + expiryTokenInHours * 60 * 60 * 1000);
|
|
35
35
|
await this.userSessionRepository.saveSession(userSession);
|
|
36
|
-
const payload = {
|
|
36
|
+
const payload = {
|
|
37
|
+
userId: user.id,
|
|
38
|
+
sessionToken,
|
|
39
|
+
appcode: appcode,
|
|
40
|
+
email_id: user.email_id,
|
|
41
|
+
};
|
|
37
42
|
const accessToken = this.jwtAuthService.generateJwt(payload);
|
|
38
43
|
userSession.access_token = accessToken;
|
|
39
44
|
await this.userSessionRepository.saveSession(userSession);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-session.service.js","sourceRoot":"","sources":["../../../../src/module/user/service/user-session.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uEAA4D;AAC5D,0FAAkF;AAClF,2CAA4C;AAC5C,iFAA6E;AAC7E,iEAAsE;AACtE,2CAA+C;AAGxC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YACmB,qBAA4C,EAC5C,cAA8B,EAC9B,iBAAoC,EAC7C,aAA4B;QAHnB,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,mBAAc,GAAd,cAAc,CAAgB;QAC9B,sBAAiB,GAAjB,iBAAiB,CAAmB;QAC7C,kBAAa,GAAb,aAAa,CAAe;IACnC,CAAC;IACJ,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,OAAgB;QACxC,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAE/D,MAAM,WAAW,GAAQ,IAAI,iCAAW,EAAE,CAAC;QAC3C,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC;QAC9B,WAAW,CAAC,WAAW,GAAG,YAAY,CAAC;QACvC,WAAW,CAAC,oBAAoB,GAAG,CAAC,CAAC;QACrC,WAAW,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;QACpC,MAAM,kBAAkB,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACvE,WAAW,CAAC,WAAW,GAAG,IAAI,IAAI,CAChC,IAAI,CAAC,GAAG,EAAE,GAAG,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CACjD,CAAC;QAEF,MAAM,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QAE1D,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"user-session.service.js","s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