Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/d-rec/drec-origin into D…
Browse files Browse the repository at this point in the history
…R-839_Update_User_Fix
  • Loading branch information
Aish1990 committed Jul 8, 2024
2 parents c01cd53 + 093e0fb commit d4abe69
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion 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
6 changes: 5 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

0 comments on commit d4abe69

Please sign in to comment.