rez_core 2.0.9 → 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/meta/entity/preference.entity.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/meta/entity/preference.entity.ts +0 -2
- package/src/module/user/service/user-session.service.ts +6 -1
package/package.json
CHANGED
|
@@ -11,32 +11,32 @@ import { ConfigService } from '@nestjs/config';
|
|
|
11
11
|
export class JwtStrategy extends PassportStrategy(Strategy) {
|
|
12
12
|
constructor(
|
|
13
13
|
@InjectRepository(UserSession)
|
|
14
|
-
private userSessionRepository: Repository<UserSession>,
|
|
14
|
+
// private userSessionRepository: Repository<UserSession>,
|
|
15
15
|
private configService: ConfigService,
|
|
16
16
|
) {
|
|
17
17
|
super({
|
|
18
18
|
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
19
19
|
ignoreExpiration: false,
|
|
20
|
-
secretOrKey:configService.get('SECRET_KEY'),
|
|
20
|
+
secretOrKey: configService.get('SECRET_KEY'),
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
async validate(payload) {
|
|
25
|
-
const { userId, sessionToken,appcode } = payload;
|
|
25
|
+
const { userId, sessionToken, appcode, email_id } = payload;
|
|
26
26
|
|
|
27
27
|
// Check if session exists and is valid
|
|
28
|
-
const userSession = await this.userSessionRepository.findOne({
|
|
29
|
-
|
|
30
|
-
});
|
|
28
|
+
// const userSession = await this.userSessionRepository.findOne({
|
|
29
|
+
// where: { session_key: sessionToken },
|
|
30
|
+
// });
|
|
31
31
|
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
) {
|
|
37
|
-
|
|
38
|
-
}
|
|
32
|
+
// if (
|
|
33
|
+
// !userSession ||
|
|
34
|
+
// userSession.is_session_loggedout ||
|
|
35
|
+
// new Date(userSession.expiry_date) < new Date()
|
|
36
|
+
// ) {
|
|
37
|
+
// throw new UnauthorizedException('Invalid or expired session');
|
|
38
|
+
// }
|
|
39
39
|
|
|
40
|
-
return { userId, sessionToken ,
|
|
40
|
+
return { userId, sessionToken, appcode, email_id };
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -28,7 +28,12 @@ export class UserSessionService {
|
|
|
28
28
|
|
|
29
29
|
await this.userSessionRepository.saveSession(userSession);
|
|
30
30
|
|
|
31
|
-
const payload = {
|
|
31
|
+
const payload = {
|
|
32
|
+
userId: user.id,
|
|
33
|
+
sessionToken,
|
|
34
|
+
appcode: appcode,
|
|
35
|
+
email_id: user.email_id,
|
|
36
|
+
};
|
|
32
37
|
const accessToken = this.jwtAuthService.generateJwt(payload);
|
|
33
38
|
|
|
34
39
|
userSession.access_token = accessToken;
|