Skip to content

Commit

Permalink
Merge pull request #790 from credebl/feat/create-client-keycloak
Browse files Browse the repository at this point in the history
fix: fetch clientId and client secret by userId
  • Loading branch information
KulkarniShashank authored Jun 19, 2024
2 parents 49fa9a8 + 9bcc3c2 commit ffca3a1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions apps/organization/src/organization.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ export class OrganizationService {
}

async deleteClientCredentials(orgId: string, user: user): Promise<string> {
const token = await this.clientRegistrationService.getManagementToken(user.clientId, user.clientSecret);
const getUser = await this.organizationRepository.getUser(user?.id);
const token = await this.clientRegistrationService.getManagementToken(getUser.clientId, getUser.clientSecret);

const organizationDetails = await this.organizationRepository.getOrganizationDetails(orgId);

Expand Down Expand Up @@ -755,7 +756,8 @@ export class OrganizationService {
return this.orgRoleService.getOrgRoles();
}

const token = await this.clientRegistrationService.getManagementToken(user.clientId, user.clientSecret);
const getUser = await this.organizationRepository.getUser(user?.id);
const token = await this.clientRegistrationService.getManagementToken(getUser?.clientId, getUser?.clientSecret);

return this.clientRegistrationService.getAllClientRoles(organizationDetails.idpId, token);
} catch (error) {
Expand Down Expand Up @@ -1465,9 +1467,10 @@ export class OrganizationService {

async deleteOrganization(orgId: string, user: user): Promise<IDeleteOrganization> {
try {
const getUser = await this.organizationRepository.getUser(user?.id);
// Fetch token and organization details in parallel
const [token, organizationDetails] = await Promise.all([
this.clientRegistrationService.getManagementToken(user.clientId, user.clientSecret),
this.clientRegistrationService.getManagementToken(getUser?.clientId, getUser?.clientSecret),
this.organizationRepository.getOrganizationDetails(orgId)
]);

Expand Down

0 comments on commit ffca3a1

Please sign in to comment.