rez_core 2.2.68 → 2.2.69
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/layout_preference/service/layout_preference.service.js +2 -0
- package/dist/module/layout_preference/service/layout_preference.service.js.map +1 -1
- package/dist/module/notification/controller/otp.controller.d.ts +18 -5
- package/dist/module/notification/controller/otp.controller.js +2 -10
- package/dist/module/notification/controller/otp.controller.js.map +1 -1
- package/dist/module/notification/notification.module.js +2 -0
- package/dist/module/notification/notification.module.js.map +1 -1
- package/dist/module/notification/service/otp.service.d.ts +26 -11
- package/dist/module/notification/service/otp.service.js +16 -29
- package/dist/module/notification/service/otp.service.js.map +1 -1
- package/dist/module/user/service/login.service.d.ts +1 -1
- package/dist/module/user/service/login.service.js +32 -14
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/module/workflow/repository/activity-log.repository.js +1 -0
- package/dist/module/workflow/repository/activity-log.repository.js.map +1 -1
- package/dist/module/workflow/repository/task.repository.js +3 -0
- package/dist/module/workflow/repository/task.repository.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/layout_preference/service/layout_preference.service.ts +2 -0
- package/src/module/notification/controller/otp.controller.ts +4 -10
- package/src/module/notification/notification.module.ts +2 -0
- package/src/module/notification/service/otp.service.ts +16 -34
- package/src/module/user/service/login.service.ts +38 -20
- package/src/module/workflow/repository/activity-log.repository.ts +1 -0
- package/src/module/workflow/repository/task.repository.ts +7 -1
package/package.json
CHANGED
|
@@ -24,6 +24,7 @@ export class LayoutPreferenceService extends EntityServiceImpl {
|
|
|
24
24
|
throw new Error('User ID is required to create layout preference.');
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
console.log(mapped_entity_type, loggedInUser, userId);
|
|
27
28
|
const existingLayoutPreference =
|
|
28
29
|
await this.layoutPreferenceRepository.findByEntityUserId(
|
|
29
30
|
mapped_entity_type,
|
|
@@ -32,6 +33,7 @@ export class LayoutPreferenceService extends EntityServiceImpl {
|
|
|
32
33
|
userId,
|
|
33
34
|
);
|
|
34
35
|
|
|
36
|
+
console.log(existingLayoutPreference, 'existingLayoutPreference');
|
|
35
37
|
if (existingLayoutPreference) {
|
|
36
38
|
return await super.updateEntity(
|
|
37
39
|
{ ...entityData, id: existingLayoutPreference.id },
|
|
@@ -43,16 +43,10 @@ export class OtpController {
|
|
|
43
43
|
|
|
44
44
|
@Post('verify')
|
|
45
45
|
@HttpCode(HttpStatus.OK)
|
|
46
|
-
async verifyOtp(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
message: 'OTP verified successfully!',
|
|
53
|
-
success: true,
|
|
54
|
-
data: verify,
|
|
55
|
-
};
|
|
46
|
+
async verifyOtp(
|
|
47
|
+
@Body() body: { otp: string; otp_id: string; identifier: string },
|
|
48
|
+
) {
|
|
49
|
+
return await this.otpService.verifyOtp(body);
|
|
56
50
|
}
|
|
57
51
|
|
|
58
52
|
@Post('send-mail')
|
|
@@ -10,6 +10,7 @@ import { EmailService } from './service/email.service';
|
|
|
10
10
|
import { join } from 'path';
|
|
11
11
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
12
12
|
import { AuthModule } from '../auth/auth.module';
|
|
13
|
+
import { UserModule } from '../user/user.module';
|
|
13
14
|
|
|
14
15
|
@Module({
|
|
15
16
|
imports: [
|
|
@@ -40,6 +41,7 @@ import { AuthModule } from '../auth/auth.module';
|
|
|
40
41
|
}),
|
|
41
42
|
}),
|
|
42
43
|
AuthModule,
|
|
44
|
+
UserModule,
|
|
43
45
|
],
|
|
44
46
|
providers: [OtpService, OtpRepository, EmailService],
|
|
45
47
|
exports: [OtpService, EmailService],
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { OtpRepository } from '../repository/otp.repository';
|
|
3
|
-
import { Otp } from '../entity/otp.entity';
|
|
4
|
-
import { ClockIDGenService } from '../../../utils/service/clockIDGenUtil.service';
|
|
1
|
+
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
5
2
|
import { ConfigService } from '@nestjs/config';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { ClockIDGenService } from '../../../utils/service/clockIDGenUtil.service';
|
|
4
|
+
import { Otp } from '../entity/otp.entity';
|
|
5
|
+
import { OtpRepository } from '../repository/otp.repository';
|
|
6
|
+
import { LoginService } from './../../user/service/login.service';
|
|
8
7
|
|
|
9
8
|
@Injectable()
|
|
10
9
|
export class OtpService {
|
|
@@ -12,9 +11,7 @@ export class OtpService {
|
|
|
12
11
|
private readonly otpRepository: OtpRepository,
|
|
13
12
|
private readonly idGen: ClockIDGenService,
|
|
14
13
|
private configService: ConfigService,
|
|
15
|
-
|
|
16
|
-
private readonly jwtAuthService: JwtAuthService,
|
|
17
|
-
private databaseSource: DataSource,
|
|
14
|
+
private readonly loginService: LoginService,
|
|
18
15
|
) {}
|
|
19
16
|
|
|
20
17
|
VERIFY_OTP = this.configService.get('VERIFY_OTP') || 'true';
|
|
@@ -41,18 +38,21 @@ export class OtpService {
|
|
|
41
38
|
return await this.otpRepository.save(otp);
|
|
42
39
|
}
|
|
43
40
|
|
|
44
|
-
async verifyOtp(
|
|
41
|
+
async verifyOtp(body: { otp: string; otp_id: string; identifier: string }) {
|
|
45
42
|
let verifyOTPResponse = {
|
|
46
43
|
isValid: false,
|
|
47
|
-
access_token: '',
|
|
48
44
|
};
|
|
49
45
|
|
|
50
|
-
let otp =
|
|
51
|
-
let otpId =
|
|
46
|
+
let otp = body.otp;
|
|
47
|
+
let otpId = body.otp_id;
|
|
52
48
|
|
|
53
49
|
let otpEntity = await this.findByOtpId(otpId);
|
|
54
50
|
|
|
55
51
|
if (otpEntity) {
|
|
52
|
+
if (otpEntity.identifier !== body.identifier) {
|
|
53
|
+
throw new BadRequestException('Invalid OTP!');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
56
|
if (
|
|
57
57
|
otpEntity.otp === otp &&
|
|
58
58
|
new Date(Date.now()) <= otpEntity.expiration_date &&
|
|
@@ -69,28 +69,10 @@ export class OtpService {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
if (verifyOTPResponse.isValid
|
|
73
|
-
|
|
74
|
-
const entity_id = request.entity.entity_id;
|
|
75
|
-
|
|
76
|
-
const entityData = await this.databaseSource.query(
|
|
77
|
-
`SELECT level_id, level_type, organization_id FROM ether_core.crm_lead where id = ${entity_id}`,
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
if (entityData.length > 0) {
|
|
81
|
-
const level_id = entityData[0].level_id;
|
|
82
|
-
const level_type = entityData[0].level_type;
|
|
83
|
-
const organization_id = entityData[0].organization_id;
|
|
84
|
-
|
|
85
|
-
verifyOTPResponse.access_token = await this.jwtAuthService.generateJwt({
|
|
86
|
-
level_id: level_id,
|
|
87
|
-
level_type: level_type,
|
|
88
|
-
organization_id: organization_id,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
72
|
+
if (!verifyOTPResponse.isValid) {
|
|
73
|
+
throw new BadRequestException('Invalid OTP!');
|
|
91
74
|
}
|
|
92
|
-
|
|
93
|
-
return verifyOTPResponse;
|
|
75
|
+
return await this.loginService.login(body.identifier, undefined, true);
|
|
94
76
|
}
|
|
95
77
|
|
|
96
78
|
async findByOtpId(otpId: string) {
|
|
@@ -36,7 +36,7 @@ export class LoginService {
|
|
|
36
36
|
masterKey: string = this.configService.get('MASTER_KEY') || '';
|
|
37
37
|
masterIv: string = this.configService.get('MASTER_IV') || '';
|
|
38
38
|
|
|
39
|
-
async login(email: string, password
|
|
39
|
+
async login(email: string, password?: string, is_otp = false) {
|
|
40
40
|
const user = await this.userService.findByEmailId(email);
|
|
41
41
|
|
|
42
42
|
console.log(user, ' user data');
|
|
@@ -71,18 +71,20 @@ export class LoginService {
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
if (!is_otp) {
|
|
75
|
+
const encryptedPassword = EncryptUtilService.encryptGCM(
|
|
76
|
+
password,
|
|
77
|
+
this.masterKey,
|
|
78
|
+
this.masterIv,
|
|
79
|
+
);
|
|
79
80
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
if (encryptedPassword !== user.password) {
|
|
82
|
+
return {
|
|
83
|
+
success: false,
|
|
84
|
+
message: 'Oops! Your password is incorrect.',
|
|
85
|
+
type: 'password',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
let appcode = user.last_app_access;
|
|
@@ -107,12 +109,12 @@ export class LoginService {
|
|
|
107
109
|
user.id,
|
|
108
110
|
defaultAccess.level_type,
|
|
109
111
|
defaultAccess.level_id,
|
|
110
|
-
defaultAccess.appcode
|
|
112
|
+
defaultAccess.appcode,
|
|
111
113
|
);
|
|
112
114
|
|
|
113
115
|
const token = await this.userSessionService.createSession(
|
|
114
116
|
user,
|
|
115
|
-
appcode,
|
|
117
|
+
defaultAccess.appcode,
|
|
116
118
|
defaultAccess,
|
|
117
119
|
);
|
|
118
120
|
|
|
@@ -132,7 +134,7 @@ export class LoginService {
|
|
|
132
134
|
return {
|
|
133
135
|
success: true,
|
|
134
136
|
accessToken: token,
|
|
135
|
-
appcode,
|
|
137
|
+
appcode: defaultAccess.appcode,
|
|
136
138
|
level_type: defaultAccess.level_type,
|
|
137
139
|
level_id: defaultAccess.level_id,
|
|
138
140
|
};
|
|
@@ -168,7 +170,7 @@ export class LoginService {
|
|
|
168
170
|
private async getDefaultAccess(
|
|
169
171
|
user: any,
|
|
170
172
|
roleMappings: any[],
|
|
171
|
-
): Promise<{ level_type: string; level_id: string
|
|
173
|
+
): Promise<{ level_type: string; level_id: string; appcode: string }> {
|
|
172
174
|
const orgAccess = roleMappings.find((r) => r.level_type === 'ORG');
|
|
173
175
|
const brnAccesses = roleMappings.filter((r) => r.level_type === 'BRN');
|
|
174
176
|
const schAccesses = roleMappings.filter((r) => r.level_type === 'SCH');
|
|
@@ -180,11 +182,19 @@ export class LoginService {
|
|
|
180
182
|
);
|
|
181
183
|
|
|
182
184
|
if (user.last_level_type && user.last_level_id && validURM) {
|
|
183
|
-
return {
|
|
185
|
+
return {
|
|
186
|
+
level_type: user.last_level_type,
|
|
187
|
+
level_id: user.last_level_id,
|
|
188
|
+
appcode: user.last_app_access,
|
|
189
|
+
};
|
|
184
190
|
}
|
|
185
191
|
|
|
186
192
|
if (orgAccess) {
|
|
187
|
-
return {
|
|
193
|
+
return {
|
|
194
|
+
level_type: 'ORG',
|
|
195
|
+
level_id: orgAccess.level_id,
|
|
196
|
+
appcode: orgAccess.appcode,
|
|
197
|
+
};
|
|
188
198
|
}
|
|
189
199
|
|
|
190
200
|
if (brnAccesses.length) {
|
|
@@ -196,7 +206,11 @@ export class LoginService {
|
|
|
196
206
|
);
|
|
197
207
|
|
|
198
208
|
if (rows.length) {
|
|
199
|
-
return {
|
|
209
|
+
return {
|
|
210
|
+
level_type: 'SCH',
|
|
211
|
+
level_id: rows[0].id,
|
|
212
|
+
appcode: brnAccesses[0].appcode,
|
|
213
|
+
};
|
|
200
214
|
} else {
|
|
201
215
|
throw new BadRequestException(
|
|
202
216
|
'User has BRN access but no schools found under that brand.',
|
|
@@ -205,7 +219,11 @@ export class LoginService {
|
|
|
205
219
|
}
|
|
206
220
|
|
|
207
221
|
if (schAccesses.length) {
|
|
208
|
-
return {
|
|
222
|
+
return {
|
|
223
|
+
level_type: 'SCH',
|
|
224
|
+
level_id: schAccesses[0].level_id,
|
|
225
|
+
appcode: schAccesses[0].appcode,
|
|
226
|
+
};
|
|
209
227
|
}
|
|
210
228
|
|
|
211
229
|
throw new BadRequestException(
|
|
@@ -34,6 +34,11 @@ export class TaskRepository {
|
|
|
34
34
|
[loggedInUser.organization_id],
|
|
35
35
|
);
|
|
36
36
|
|
|
37
|
+
const leadData = await this.dataSource.query(
|
|
38
|
+
`SELECT * FROM crm_lead WHERE id = ?`,
|
|
39
|
+
[mapped_entity_id],
|
|
40
|
+
);
|
|
41
|
+
|
|
37
42
|
// Find the action with the lowest sequence
|
|
38
43
|
|
|
39
44
|
if (action.length > 0) {
|
|
@@ -54,10 +59,11 @@ export class TaskRepository {
|
|
|
54
59
|
is_mandatory: is_mandatory[0]?.code === 'mandatory' ? true : false,
|
|
55
60
|
mapped_entity_id,
|
|
56
61
|
mapped_entity_type,
|
|
57
|
-
|
|
62
|
+
due_date: new Date(new Date().setDate(new Date().getDate() + 2)),
|
|
58
63
|
is_system: true,
|
|
59
64
|
status: todoListMasterItemId[0]?.id,
|
|
60
65
|
category: act?.action_category_code,
|
|
66
|
+
task_owner: leadData[0]?.lead_owner,
|
|
61
67
|
} as TaskDataEntity);
|
|
62
68
|
await this.TaskRepository.save(taskData);
|
|
63
69
|
}
|