Skip to content

Commit

Permalink
Revert "[perms] Implement getTeams WEB-501 (#18039)" (#18057)
Browse files Browse the repository at this point in the history
This reverts commit 0111756.
  • Loading branch information
geropl authored Jun 26, 2023
1 parent 8a2be48 commit c94224b
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions components/server/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2748,35 +2748,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
public async getTeams(ctx: TraceContext): Promise<Team[]> {
// Note: this operation is per-user only, hence needs no resource guard
const user = await this.checkUser("getTeams");
const teams = await this.teamDB.findTeamsByUser(user.id);

// We need to check each team individually against our permission system.
// checks are promises, which resolve to { team, check } object
const checks = teams.map((team) =>
this.authorizer.check(ReadOrganizationInfo(user.id, team.id)).then((check) => ({ team, check })),
);
const checkResults = await Promise.allSettled(checks);

const accessibleTeams = [];
const errors = [];
for (let result of checkResults) {
if (result.status !== "fulfilled") {
errors.push(result.reason);
continue;
}

const { team, check } = result.value;

if (check.permitted) {
accessibleTeams.push(team);
}
}

if (errors.length > 0) {
log.warn(`Failed to check for permissions on getTeams for at least one team`, { errors });
}

return accessibleTeams;
return this.teamDB.findTeamsByUser(user.id);
}

public async getTeam(ctx: TraceContext, teamId: string): Promise<Team> {
Expand Down

0 comments on commit c94224b

Please sign in to comment.