diff --git a/apps/drec-api/src/pods/admin/admin.controller.ts b/apps/drec-api/src/pods/admin/admin.controller.ts index 3f213b030..abeafa9cd 100755 --- a/apps/drec-api/src/pods/admin/admin.controller.ts +++ b/apps/drec-api/src/pods/admin/admin.controller.ts @@ -161,7 +161,11 @@ export class AdminController { type: CreateUserORGDTO, description: 'Returns a new created user', }) - public async createUser(@Body() newUser: CreateUserORGDTO): Promise { + public async createUser( + @Body() newUser: CreateUserORGDTO, + @UserDecorator() { api_user_id }: LoggedInUser, + ): Promise { + newUser.api_user_id = api_user_id; return await this.userService.adminnewcreate(newUser); } diff --git a/apps/drec-api/src/pods/user/user.service.ts b/apps/drec-api/src/pods/user/user.service.ts index 3b3072b2c..3a050e4c8 100755 --- a/apps/drec-api/src/pods/user/user.service.ts +++ b/apps/drec-api/src/pods/user/user.service.ts @@ -166,6 +166,9 @@ export class UserService { inviteuser?: boolean, ): Promise { await this.checkForExistingUser(data.email.toLowerCase()); + const admin = await this.oauthClientCredentialsService.findOneByApiUserId( + data.api_user_id, + ); let org_id; if (!inviteuser) { const orgdata = { @@ -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, @@ -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(