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

DR-839 Fixed Add Organization at admin login fixed as it was not updating th… #349

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading