Skip to content

Commit 522c491

Browse files
Merge pull request #7 from neuralarchitects/dashboard
fix: enhance data validation for device coordinates and exclude sensi…
2 parents 1a544f7 + c07c9f2 commit 522c491

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

admin_web_app/Source_webapp/src/views/crm/CrmDashboard/CrmDashboard.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,15 @@ const CrmDashboard = () => {
4747
if (devices?.data.data) {
4848
const newPositions: [number, number, number, number][] =
4949
devices.data.data
50-
.filter((item) => item.location.coordinates)
50+
.filter(
51+
(item) =>
52+
Array.isArray(item.location.coordinates) &&
53+
item.location.coordinates.length === 2 &&
54+
typeof item.location.coordinates[0] === 'number' &&
55+
typeof item.location.coordinates[1] === 'number' &&
56+
item.location.coordinates[0] !== null &&
57+
item.location.coordinates[1] !== null
58+
)
5159
.map(
5260
(item: any) =>
5361
[

backend/src/modules/authentication/authentication.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export class AuthenticationService {
4545
});
4646

4747
if (passwordIsCorrect) {
48+
user.password = undefined;
49+
user.newPassword = undefined;
4850
return { user: user, error: null };
4951
} else {
5052
return { user: null, error: 'passwordIncorrect' };

backend/src/modules/user/services/user/user.service.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,15 @@ export class UserService {
9292
private readonly buildingService?: BuildingService,
9393
) {}
9494

95-
getUserKeys(): string {
96-
return Object.keys(userSchema.paths).join(' ');
95+
getUserKeys(exclude=true): string {
96+
const excludedFields = ['password', 'newPassword'];
97+
if (exclude) {
98+
return Object.keys(userSchema.paths)
99+
.filter(key => !excludedFields.includes(key))
100+
.join(' ');
97101
}
102+
return Object.keys(userSchema.paths).join(' ');
103+
}
98104

99105
validateEmail(email: string) {
100106
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
@@ -1446,7 +1452,7 @@ export class UserService {
14461452
},
14471453
},
14481454
];
1449-
const selectCondition = this.getUserKeys();
1455+
const selectCondition = this.getUserKeys(false);
14501456

14511457
this.user = await this.userRepository.findUserByEmail(
14521458
data.email,
@@ -1556,7 +1562,7 @@ export class UserService {
15561562
},
15571563
];
15581564

1559-
const selectCondition = this.getUserKeys();
1565+
const selectCondition = this.getUserKeys(false);
15601566

15611567
this.user = await this.userRepository.findUserByEmail(
15621568
data.email,

0 commit comments

Comments
 (0)