rez_core 2.2.201 → 2.2.202
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/communication/service/wrapper.service.js +40 -2
- package/dist/module/communication/service/wrapper.service.js.map +1 -1
- package/dist/module/communication/strategies/gmail.strategy.js +1 -1
- package/dist/module/communication/strategies/gmail.strategy.js.map +1 -1
- package/dist/module/notification/controller/otp.controller.js +0 -1
- package/dist/module/notification/controller/otp.controller.js.map +1 -1
- package/dist/module/user/controller/login.controller.js +11 -3
- package/dist/module/user/controller/login.controller.js.map +1 -1
- package/dist/module/user/service/login.service.d.ts +7 -6
- package/dist/module/user/service/login.service.js +9 -2
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/communication/service/wrapper.service.ts +50 -2
- package/src/module/communication/strategies/gmail.strategy.ts +1 -1
- package/src/module/notification/controller/otp.controller.ts +0 -1
- package/src/module/user/controller/login.controller.ts +13 -3
- package/src/module/user/service/login.service.ts +16 -8
package/package.json
CHANGED
|
@@ -149,6 +149,7 @@ export class WrapperService {
|
|
|
149
149
|
|
|
150
150
|
let configCred;
|
|
151
151
|
let result;
|
|
152
|
+
let payloadSendMail: GenericMessageDto;
|
|
152
153
|
|
|
153
154
|
if (configs && configs.length > 0) {
|
|
154
155
|
// only if type is gmail
|
|
@@ -156,21 +157,68 @@ export class WrapperService {
|
|
|
156
157
|
`SELECT config_json
|
|
157
158
|
FROM cr_communication_config
|
|
158
159
|
WHERE id = ?`,
|
|
159
|
-
[configs[0]
|
|
160
|
+
[configs[0]?.config_id],
|
|
160
161
|
);
|
|
161
162
|
|
|
162
163
|
if (!configCred || configCred.length === 0) {
|
|
163
164
|
throw new Error('No Google credentials found for user-level config');
|
|
164
165
|
}
|
|
165
166
|
|
|
166
|
-
configCred = configCred[0]
|
|
167
|
+
configCred = configCred[0]?.config_json;
|
|
167
168
|
// 3. Call google service
|
|
168
169
|
result = await this.googleService.createEvent(configCred, payload);
|
|
170
|
+
} else if (configs && configs.length === 0) {
|
|
171
|
+
// 2. Fallback → ORG-level config
|
|
172
|
+
const fallbackConfigs = await this.datasource.query(
|
|
173
|
+
`SELECT *
|
|
174
|
+
FROM cr_communication_hub
|
|
175
|
+
WHERE level_type = ? AND level_id = ?
|
|
176
|
+
AND communication_config_type = 'EMAIL' AND service = 'API'`,
|
|
177
|
+
[level_type, level_id],
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
if (fallbackConfigs && fallbackConfigs.length > 0) {
|
|
181
|
+
configCred = await this.datasource.query(
|
|
182
|
+
`SELECT config_json
|
|
183
|
+
FROM cr_communication_config
|
|
184
|
+
WHERE id = ?`,
|
|
185
|
+
[fallbackConfigs[0].config_id],
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const base64String = await this.icsService.generateIcs(payload);
|
|
189
|
+
|
|
190
|
+
payloadSendMail = {
|
|
191
|
+
levelId: level_id,
|
|
192
|
+
levelType: level_type,
|
|
193
|
+
to: payload.to,
|
|
194
|
+
message: payload.message,
|
|
195
|
+
subject: payload.subject,
|
|
196
|
+
type: 'EMAIL',
|
|
197
|
+
cc: payload.cc,
|
|
198
|
+
bcc: payload.bcc,
|
|
199
|
+
html: payload.html,
|
|
200
|
+
attachments: [
|
|
201
|
+
{
|
|
202
|
+
content: base64String,
|
|
203
|
+
type: 'text/calendar',
|
|
204
|
+
filename: 'invite.ics',
|
|
205
|
+
disposition: 'attachment',
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
templateId: payload.templateId,
|
|
209
|
+
variables: payload.variables,
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
result =
|
|
213
|
+
await this.communicationService.sendGenericMessage(payloadSendMail);
|
|
214
|
+
}
|
|
169
215
|
} else {
|
|
170
216
|
const base64String = await this.icsService.generateIcs(payload);
|
|
171
217
|
|
|
172
218
|
result = await this.communicationService.sendGenericMessage({
|
|
173
219
|
...payload,
|
|
220
|
+
levelId: 1,
|
|
221
|
+
levelType: 'ORG',
|
|
174
222
|
attachments: [
|
|
175
223
|
{
|
|
176
224
|
content: base64String,
|
|
@@ -66,7 +66,7 @@ export class GmailStrategy implements CommunicationStrategy {
|
|
|
66
66
|
`Subject: ${subject}`,
|
|
67
67
|
'Content-Type: text/html; charset=utf-8',
|
|
68
68
|
'',
|
|
69
|
-
config.html
|
|
69
|
+
message || config.html,
|
|
70
70
|
].join('\n');
|
|
71
71
|
|
|
72
72
|
const encodedMessage = Buffer.from(emailContent)
|
|
@@ -16,6 +16,7 @@ import { Request, Response } from 'express';
|
|
|
16
16
|
import { UserSessionService } from '../service/user-session.service';
|
|
17
17
|
import { ConfigService } from '@nestjs/config';
|
|
18
18
|
import { CommunicationService } from '../../communication/service/communication.service';
|
|
19
|
+
import { UAParser } from 'ua-parser-js';
|
|
19
20
|
|
|
20
21
|
@Controller('auth')
|
|
21
22
|
export class LoginController {
|
|
@@ -77,7 +78,6 @@ export class LoginController {
|
|
|
77
78
|
async googleAuthRedirect(@Req() req: any, @Res() res: Response) {
|
|
78
79
|
const {
|
|
79
80
|
email,
|
|
80
|
-
password,
|
|
81
81
|
name,
|
|
82
82
|
accessToken: googleAccessToken,
|
|
83
83
|
refreshToken: googleRefreshToken,
|
|
@@ -86,6 +86,15 @@ export class LoginController {
|
|
|
86
86
|
} = req.user;
|
|
87
87
|
const { state } = req.query;
|
|
88
88
|
|
|
89
|
+
const ip =
|
|
90
|
+
(req.headers['x-forwarded-for'] as string)?.split(',')[0].trim() ||
|
|
91
|
+
req.socket.remoteAddress;
|
|
92
|
+
|
|
93
|
+
const userAgent = req.headers['user-agent'] || '';
|
|
94
|
+
const parser = new UAParser(userAgent);
|
|
95
|
+
const browser = parser.getBrowser().name || 'Unknown';
|
|
96
|
+
const os = parser.getOS().name || 'Unknown';
|
|
97
|
+
|
|
89
98
|
// Check if this is a Gmail configuration request
|
|
90
99
|
if (
|
|
91
100
|
state &&
|
|
@@ -114,10 +123,11 @@ export class LoginController {
|
|
|
114
123
|
// Original login flow
|
|
115
124
|
const data = await this.loginService.loginWithGoogle({
|
|
116
125
|
email,
|
|
117
|
-
password,
|
|
118
|
-
name,
|
|
119
126
|
subdomain,
|
|
120
127
|
fcm_token,
|
|
128
|
+
ip,
|
|
129
|
+
browser,
|
|
130
|
+
os,
|
|
121
131
|
});
|
|
122
132
|
|
|
123
133
|
if (!('accessToken' in data) || !data.accessToken)
|
|
@@ -41,8 +41,8 @@ export class LoginService {
|
|
|
41
41
|
async login(data: {
|
|
42
42
|
email: string;
|
|
43
43
|
password?: string;
|
|
44
|
-
subdomain
|
|
45
|
-
fcm_token
|
|
44
|
+
subdomain?: string;
|
|
45
|
+
fcm_token?: string;
|
|
46
46
|
is_otp?: boolean;
|
|
47
47
|
browser?: string;
|
|
48
48
|
ip?: string;
|
|
@@ -282,12 +282,13 @@ export class LoginService {
|
|
|
282
282
|
|
|
283
283
|
async loginWithGoogle(data: {
|
|
284
284
|
email: string;
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
285
|
+
subdomain?: string;
|
|
286
|
+
fcm_token?: string;
|
|
287
|
+
ip?: string;
|
|
288
|
+
browser?: string;
|
|
289
|
+
os?: string;
|
|
289
290
|
}) {
|
|
290
|
-
const { email,
|
|
291
|
+
const { email, subdomain, fcm_token, ip, browser, os } = data;
|
|
291
292
|
const user = await this.userService.findByEmailId(email);
|
|
292
293
|
|
|
293
294
|
if (!user) {
|
|
@@ -311,7 +312,14 @@ export class LoginService {
|
|
|
311
312
|
}
|
|
312
313
|
|
|
313
314
|
// Create session (Same as JWT login flow)
|
|
314
|
-
return await this.login(
|
|
315
|
+
return await this.login({
|
|
316
|
+
email,
|
|
317
|
+
subdomain,
|
|
318
|
+
fcm_token,
|
|
319
|
+
ip,
|
|
320
|
+
browser,
|
|
321
|
+
os,
|
|
322
|
+
});
|
|
315
323
|
}
|
|
316
324
|
|
|
317
325
|
async logout(sessionKey: string) {
|