rez_core 2.0.10 → 2.0.12
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/core.module.js +2 -6
- package/dist/core.module.js.map +1 -1
- package/dist/module/auth/strategies/jwt.strategy.d.ts +3 -5
- package/dist/module/auth/strategies/jwt.strategy.js +4 -21
- package/dist/module/auth/strategies/jwt.strategy.js.map +1 -1
- package/dist/module/layout/controller/layout.controller.js +2 -2
- package/dist/module/layout/controller/layout.controller.js.map +1 -1
- package/dist/module/layout/layout.module.js +5 -1
- package/dist/module/layout/layout.module.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/core.module.ts +13 -6
- package/src/module/auth/strategies/jwt.strategy.ts +14 -18
- package/src/module/layout/controller/layout.controller.ts +23 -8
- package/src/module/layout/layout.module.ts +5 -1
- package/src/module/user/service/user-session.service.ts +6 -1
package/package.json
CHANGED
package/src/core.module.ts
CHANGED
|
@@ -23,10 +23,8 @@ export class CoreModule {
|
|
|
23
23
|
ConfigModule.forRoot({ isGlobal: true }),
|
|
24
24
|
dbModule,
|
|
25
25
|
EntityModule,
|
|
26
|
-
EnterpriseModule,
|
|
27
26
|
UtilsModule,
|
|
28
27
|
NotificationModule,
|
|
29
|
-
LayoutModule,
|
|
30
28
|
ListMasterModule,
|
|
31
29
|
FilterModule,
|
|
32
30
|
];
|
|
@@ -35,17 +33,26 @@ export class CoreModule {
|
|
|
35
33
|
ConfigModule,
|
|
36
34
|
dbModule,
|
|
37
35
|
EntityModule,
|
|
38
|
-
|
|
36
|
+
|
|
39
37
|
UtilsModule,
|
|
40
38
|
NotificationModule,
|
|
41
|
-
LayoutModule,
|
|
42
39
|
ListMasterModule,
|
|
43
40
|
FilterModule,
|
|
44
41
|
];
|
|
45
42
|
|
|
46
43
|
if (isSso) {
|
|
47
|
-
importsArray.push(
|
|
48
|
-
|
|
44
|
+
importsArray.push(
|
|
45
|
+
UserModule,
|
|
46
|
+
ModuleModule,
|
|
47
|
+
LayoutModule,
|
|
48
|
+
EnterpriseModule,
|
|
49
|
+
);
|
|
50
|
+
exportsArray.push(
|
|
51
|
+
UserModule,
|
|
52
|
+
ModuleModule,
|
|
53
|
+
LayoutModule,
|
|
54
|
+
EnterpriseModule,
|
|
55
|
+
);
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
return {
|
|
@@ -9,34 +9,30 @@ import { ConfigService } from '@nestjs/config';
|
|
|
9
9
|
|
|
10
10
|
@Injectable()
|
|
11
11
|
export class JwtStrategy extends PassportStrategy(Strategy) {
|
|
12
|
-
constructor(
|
|
13
|
-
@InjectRepository(UserSession)
|
|
14
|
-
private userSessionRepository: Repository<UserSession>,
|
|
15
|
-
private configService: ConfigService,
|
|
16
|
-
) {
|
|
12
|
+
constructor(private readonly configService: ConfigService) {
|
|
17
13
|
super({
|
|
18
14
|
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
19
15
|
ignoreExpiration: false,
|
|
20
|
-
secretOrKey:configService.get('SECRET_KEY'),
|
|
16
|
+
secretOrKey: configService.get('SECRET_KEY'),
|
|
21
17
|
});
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
async validate(payload) {
|
|
25
|
-
const { userId, sessionToken,appcode } = payload;
|
|
21
|
+
const { userId, sessionToken, appcode, email_id } = payload;
|
|
26
22
|
|
|
27
23
|
// Check if session exists and is valid
|
|
28
|
-
const userSession = await this.userSessionRepository.findOne({
|
|
29
|
-
|
|
30
|
-
});
|
|
24
|
+
// const userSession = await this.userSessionRepository.findOne({
|
|
25
|
+
// where: { session_key: sessionToken },
|
|
26
|
+
// });
|
|
31
27
|
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
) {
|
|
37
|
-
|
|
38
|
-
}
|
|
28
|
+
// if (
|
|
29
|
+
// !userSession ||
|
|
30
|
+
// userSession.is_session_loggedout ||
|
|
31
|
+
// new Date(userSession.expiry_date) < new Date()
|
|
32
|
+
// ) {
|
|
33
|
+
// throw new UnauthorizedException('Invalid or expired session');
|
|
34
|
+
// }
|
|
39
35
|
|
|
40
|
-
return { userId, sessionToken ,
|
|
36
|
+
return { userId, sessionToken, appcode, email_id };
|
|
41
37
|
}
|
|
42
38
|
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Controller,
|
|
3
|
+
Get,
|
|
4
|
+
HttpStatus,
|
|
5
|
+
Inject,
|
|
6
|
+
Req,
|
|
7
|
+
Res,
|
|
8
|
+
UseGuards,
|
|
9
|
+
} from '@nestjs/common';
|
|
2
10
|
import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
|
|
3
11
|
import { HeaderSectionService } from '../service/header-section.service';
|
|
4
12
|
import { Request, Response } from 'express';
|
|
@@ -8,25 +16,32 @@ import { ENTITYTYPE_USER } from '../../../constant/global.constant';
|
|
|
8
16
|
@Controller('layout')
|
|
9
17
|
@UseGuards(JwtAuthGuard)
|
|
10
18
|
export class LayoutController {
|
|
11
|
-
constructor(
|
|
12
|
-
|
|
19
|
+
constructor(
|
|
20
|
+
private readonly headerSectionService: HeaderSectionService,
|
|
21
|
+
@Inject('UserService') private readonly userService: UserService,
|
|
22
|
+
) {}
|
|
13
23
|
|
|
14
24
|
@Get('header')
|
|
15
25
|
async getHeader(@Req() req: Request & { user: any }, @Res() res: Response) {
|
|
16
26
|
const userId = req.user.userId;
|
|
17
|
-
const userData = await this.userService.getEntityData(
|
|
27
|
+
const userData = await this.userService.getEntityData(
|
|
28
|
+
ENTITYTYPE_USER,
|
|
29
|
+
userId,
|
|
30
|
+
);
|
|
18
31
|
if (userData) {
|
|
19
|
-
let response = await this.headerSectionService.findByOrganizationId(
|
|
32
|
+
let response = await this.headerSectionService.findByOrganizationId(
|
|
33
|
+
userData.organization_id,
|
|
34
|
+
);
|
|
20
35
|
return res.json({
|
|
21
36
|
success: true,
|
|
22
37
|
data: response,
|
|
23
|
-
message: 'Header fetched successfully'
|
|
38
|
+
message: 'Header fetched successfully',
|
|
24
39
|
});
|
|
25
40
|
} else {
|
|
26
41
|
return res.status(HttpStatus.BAD_REQUEST).json({
|
|
27
42
|
success: false,
|
|
28
|
-
message: 'User data not found'
|
|
29
|
-
})
|
|
43
|
+
message: 'User data not found',
|
|
44
|
+
});
|
|
30
45
|
}
|
|
31
46
|
}
|
|
32
47
|
}
|
|
@@ -11,7 +11,11 @@ import { HeaderSectionService } from './service/header-section.service';
|
|
|
11
11
|
@Module({
|
|
12
12
|
imports: [TypeOrmModule.forFeature([HeaderSection, HeaderItems]), UserModule],
|
|
13
13
|
controllers: [LayoutController],
|
|
14
|
-
providers: [
|
|
14
|
+
providers: [
|
|
15
|
+
HeaderItemsRepository,
|
|
16
|
+
HeaderSectionRepository,
|
|
17
|
+
HeaderSectionService,
|
|
18
|
+
],
|
|
15
19
|
exports: [],
|
|
16
20
|
})
|
|
17
21
|
export class LayoutModule {}
|
|
@@ -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;
|