Skip to content

Commit

Permalink
send cohortids for learner in auth API
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnuvinay89 committed Feb 17, 2025
1 parent 4dc96df commit 30ca3ca
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/adapters/postgres/user-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,15 +677,24 @@ export class PostgresUserService implements IServicelocator {

const privilegeData = await this.postgresRoleService.findPrivilegeByRoleId(roleArray);
const privileges = privilegeData.map(priv => priv.name);

combinedResult.push({
let cohortIds = [];
if(roleName === 'learner') {
const mappedCohorts = await this.cohortMemberRepository.find({
where: { userId },
select: ['cohortId']
})
cohortIds = mappedCohorts.map(id => id.cohortId)
}
const result = {
tenantName: data.tenantname,
tenantId: data.tenantId,
userTenantMappingId: data.usertenantmappingid,
roleId: roleId,
roleName: roleName,
privileges: privileges
});
privileges: privileges,
...(roleName === 'learner' && { mappedCohorts: cohortIds })
}
combinedResult.push(result);
}
}

Expand Down

0 comments on commit 30ca3ca

Please sign in to comment.