Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage Push #356

Merged
merged 49 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
7522b46
Fix : Admin login we have got error as the orgId is not same as admin…
Aish1990 Jul 4, 2024
2afb639
Prettier fix
Aish1990 Jul 4, 2024
bea2939
Fixed error in date timestamp of AddReadsByAdmin
Aish1990 Jul 4, 2024
a920280
Merge pull request #346 from d-rec/Add_Reads_Fix
Aish1990 Jul 5, 2024
87ebfd7
Merge branch 'develop' of https://github.com/d-rec/drec-origin into b…
Aish1990 Jul 5, 2024
30b0c78
Merge pull request #345 from d-rec/bulk_upload_fix
Aish1990 Jul 5, 2024
3821b0c
Version Upgraded
Aish1990 Jul 5, 2024
e0a3b8d
Merge pull request #347 from d-rec/Version_Bump0.4
Aish1990 Jul 5, 2024
4ac5233
fixed get device by admin & update device by admin
Aish1990 Jul 5, 2024
99c33a1
Merge branch 'develop' of https://github.com/d-rec/drec-origin into D…
Aish1990 Jul 5, 2024
6a2f5d6
prettier fix
Aish1990 Jul 5, 2024
3e7ca29
Fixed Add Organization at admin login fixed as it was not updating th…
Aish1990 Jul 5, 2024
19ed550
update User Fixed
Aish1990 Jul 5, 2024
aa90551
Prettier lint Fixed
Aish1990 Jul 5, 2024
39127b8
Prettier lint Fixed
Aish1990 Jul 5, 2024
8ceb6fb
Fixed add delta read for Admin/apiuser
Aish1990 Jul 5, 2024
a7611d2
Merge pull request #348 from d-rec/DR-835
Aish1990 Jul 8, 2024
066ba76
Merge branch 'develop' of https://github.com/d-rec/drec-origin into D…
Aish1990 Jul 8, 2024
c01cd53
Merge branch 'develop' of https://github.com/d-rec/drec-origin into D…
Aish1990 Jul 8, 2024
093e0fb
Merge pull request #349 from d-rec/DR-839
Aish1990 Jul 8, 2024
d4abe69
Merge branch 'develop' of https://github.com/d-rec/drec-origin into D…
Aish1990 Jul 8, 2024
2ffac8e
Merge pull request #350 from d-rec/DR-839_Update_User_Fix
Aish1990 Jul 8, 2024
505a318
Version Upgraded
Aish1990 Jul 8, 2024
1f239da
Merge branch 'develop' of https://github.com/d-rec/drec-origin into V…
Aish1990 Jul 8, 2024
c7c5d96
Merge pull request #351 from d-rec/Version_Bump0.5
Aish1990 Jul 8, 2024
0a18c76
Apiuser's User Update fix
Aish1990 Jul 8, 2024
e74a371
Merge pull request #352 from d-rec/DR-839_ApiUser_User_Update_Fix
Aish1990 Jul 8, 2024
a7d8186
Version upgraded
Aish1990 Jul 8, 2024
b35957c
Merge branch 'develop' of https://github.com/d-rec/drec-origin into V…
Aish1990 Jul 8, 2024
da7a12c
Merge pull request #353 from d-rec/Version_Bump0.6
Aish1990 Jul 8, 2024
48d7be1
Merge branch 'develop' of https://github.com/d-rec/drec-origin into D…
Aish1990 Jul 8, 2024
fed032c
Merge pull request #354 from d-rec/DR-835_Add_Delta_reaf_fix
Aish1990 Jul 8, 2024
0a96f08
Version Upgraded
Aish1990 Jul 8, 2024
f685d79
Merge pull request #355 from d-rec/Version_Bump0.7
Aish1990 Jul 8, 2024
8f6da70
@energyweb libraries upgrades
Aish1990 Jul 9, 2024
90cfd24
Removed the import command as it's no longer used in our application
Aish1990 Jul 9, 2024
9bc036e
migration file correction of old issuer certificates entity
Aish1990 Jul 9, 2024
c272015
Merge branch 'develop' of https://github.com/d-rec/drec-origin into @…
Aish1990 Jul 9, 2024
9c41497
Merge pull request #357 from d-rec/@ewf_upgrades
Aish1990 Jul 9, 2024
88dfd9f
Version Upgraded
Aish1990 Jul 9, 2024
8096e99
Merge pull request #358 from d-rec/Version-Bump0.8
Aish1990 Jul 9, 2024
1b6c33a
ewf libraries issuer, origin-backend-utils, utils-general downgraded
Aish1990 Jul 10, 2024
1dcad01
Version Upgraded
Aish1990 Jul 10, 2024
9415a64
Merge pull request #360 from d-rec/Version_Bump0.8
NamrataSweya Jul 11, 2024
323616a
Merge branch 'develop' of https://github.com/d-rec/drec-origin into D…
Aish1990 Jul 11, 2024
e1f57c4
Version Upgraded
Aish1990 Jul 11, 2024
c73e65b
Merge pull request #359 from d-rec/DR-749_Ewf_downgrade
Aish1990 Jul 11, 2024
33937c0
Merge branch 'develop' of https://github.com/d-rec/drec-origin into V…
Aish1990 Jul 11, 2024
eee09a7
Merge pull request #361 from d-rec/Version_Bump0.9
Aish1990 Jul 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/drec-api/migrations/1715146626520-OldIssuerLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class OldIssuerLog1715146626520 implements MigrationInterface {
"latestCommitment" text,
"issuedPrivately" boolean NOT NULL,
"blockchainNetId" integer,
"metadata" character varying NOT NULL,
"metadata" character varying NOT NULL
)`);
}

Expand Down
12 changes: 6 additions & 6 deletions apps/drec-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
},
"dependencies": {
"@energyweb/energy-api-influxdb": "0.8.3",
"@energyweb/issuer": "6.0.2-alpha.1646058469.0",
"@energyweb/issuer-api": "0.6.2-alpha.1646058469.0",
"@energyweb/issuer": "7.0.1",
"@energyweb/issuer-api": "0.7.1",
"@energyweb/origin-247-certificate": "4.1.5",
"@energyweb/origin-backend": "11.0.2-alpha.1634225870.0",
"@energyweb/origin-backend-core": "8.0.4-alpha.1634225870.0",
"@energyweb/origin-backend-utils": "1.6.2-alpha.1634225870.0",
"@energyweb/utils-general": "11.0.5-alpha.1634225870.0",
"@energyweb/origin-backend": "11.2.3",
"@energyweb/origin-backend-core": "8.2.3",
"@energyweb/origin-backend-utils": "1.8.3",
"@energyweb/utils-general": "11.2.3",
"@ethersproject/bignumber": "5.3.0",
"@influxdata/influxdb-client": "1.9.0",
"@mapbox/timespace": "2.0.4",
Expand Down
10 changes: 7 additions & 3 deletions apps/drec-api/src/pods/admin/admin.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ export class AdminController {
type: CreateUserORGDTO,
description: 'Returns a new created user',
})
public async createUser(@Body() newUser: CreateUserORGDTO): Promise<UserDTO> {
public async createUser(
@Body() newUser: CreateUserORGDTO,
@UserDecorator() { api_user_id }: LoggedInUser,
): Promise<UserDTO> {
newUser.api_user_id = api_user_id;
return await this.userService.adminnewcreate(newUser);
}

Expand Down Expand Up @@ -222,9 +226,9 @@ export class AdminController {

@Put('/users/:id')
@UseGuards(AuthGuard('jwt'), ActiveUserGuard, RolesGuard, PermissionGuard)
@Roles(Role.Admin)
@Roles(Role.Admin, Role.ApiUser)
@Permission('Write')
@ACLModules('ADMIN_MANAGEMENT_CRUDL')
@ACLModules('ADMIN_APIUSER_ORGANIZATION_CRUDL')
@ApiBody({ type: UpdateUserDTO })
@ApiResponse({
status: HttpStatus.OK,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,17 +739,15 @@ export class BuyerReservationController {
});
}
} else {
if (orgId != organizationId) {
if (orgId != organizationId && role != Role.Admin) {
this.logger.error(
`The organizationId in query params should be same as user's organizationId`,
);
throw new BadRequestException({
success: false,
message: `The organizationId in query params should be same as user's organizationId`,
});
}

if (role === Role.Admin) {
} else if (role === Role.Admin) {
orgId = null;
}
}
Expand Down
11 changes: 9 additions & 2 deletions apps/drec-api/src/pods/device/device.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,12 @@ export class DeviceController {
): Promise<DeviceDTO | null> {
this.logger.verbose(`With in getByExternalId`);
let devicedata: Device;
if (loginUser.role === Role.ApiUser) {

if (loginUser.role === Role.ApiUser || loginUser.role === Role.Admin) {
if (loginUser.role === Role.Admin) {
loginUser.api_user_id = null;
}

devicedata =
await this.deviceService.findDeviceByDeveloperExternalIByApiUser(
id,
Expand Down Expand Up @@ -633,12 +638,14 @@ export class DeviceController {
user.organizationId = deviceToUpdate.organizationId;
}
} else {
if (user.organizationId != org.id) {
if (user.role != Role.Admin && user.organizationId != org.id) {
this.logger.error(`Unauthorized`);
throw new UnauthorizedException({
success: false,
message: 'Unauthorized',
});
} else if (user.role === Role.Admin) {
user.organizationId = deviceToUpdate.organizationId;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions apps/drec-api/src/pods/reads/reads.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ export class ReadsController extends BaseReadsController {
for (const key in ele) {
if (key === 'starttimestamp' || key === 'endtimestamp') {
if (ele[key]) {
let dateString = new Date(ele[key]).toISOString();
let dateString = ele[key].toString();
const dateTimeRegex =
/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.{0,1}\d{0,3}$/;
if (dateString.includes('.')) {
Expand Down Expand Up @@ -1160,11 +1160,11 @@ export class ReadsController extends BaseReadsController {
datesContainingNullOrEmptyValues = true;
}
const startdateformate = isValidUTCDateFormat(
ele.starttimestamp.toString(),
new Date(ele.starttimestamp).toISOString(),
);

const enddateformate = isValidUTCDateFormat(
ele.endtimestamp.toString(),
new Date(ele.endtimestamp).toISOString(),
);

if (!startdateformate || !enddateformate) {
Expand Down Expand Up @@ -1326,7 +1326,7 @@ export class ReadsController extends BaseReadsController {
datesContainingNullOrEmptyValues = true;
}
const enddateformate = isValidUTCDateFormat(
ele.endtimestamp.toISOString(),
new Date(ele.endtimestamp).toISOString(),
);

if (!enddateformate) {
Expand Down
1 change: 0 additions & 1 deletion apps/drec-api/src/pods/reads/reads.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import {
IAggregateintermediate,
} from '../../models';
import { InjectRepository } from '@nestjs/typeorm';
import { GetMarketplaceOrganizationHandler } from '@energyweb/origin-backend/dist/js/src/pods/organization/handlers/get-marketplace-organization.handler';
import { ReadStatus } from '../../utils/enums';
import { DeltaFirstRead } from './delta_firstread.entity';
import { HistoryNextInssuanceStatus } from '../../utils/enums/history_next_issuance.enum';
Expand Down
12 changes: 11 additions & 1 deletion apps/drec-api/src/pods/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ export class UserService {
inviteuser?: boolean,
): Promise<UserDTO> {
await this.checkForExistingUser(data.email.toLowerCase());
const admin = await this.oauthClientCredentialsService.findOneByApiUserId(
data.api_user_id,
);
let org_id;
if (!inviteuser) {
const orgdata = {
Expand All @@ -175,7 +178,7 @@ export class UserService {
orgEmail: data.email,
address: data.orgAddress,
};

orgdata['api_user_id'] = admin.api_user_id;
if (await this.organizationService.isNameAlreadyTaken(orgdata.name)) {
throw new ConflictException({
success: false,
Expand Down Expand Up @@ -212,6 +215,7 @@ export class UserService {
role: role,
roleId: roleId,
organization: org_id ? { id: org_id } : {},
api_user_id: admin ? admin.api_user_id : null,
});
const { password, ...userData } = user;
this.logger.debug(
Expand Down Expand Up @@ -508,6 +512,12 @@ export class UserService {
id: number,
data: UpdateUserDTO,
): Promise<ExtendedBaseEntity & IUser> {
data = new User({
firstName: data.firstName,
lastName: data.lastName,
email: data.email,
status: data.status,
});
const validationErrors = await validate(data, {
skipUndefinedProperties: true,
});
Expand Down
Loading
Loading