Skip to content

Commit 6a5440e

Browse files
selfcontainedroboquat
authored andcommitted
just use teamId for feature flag check
1 parent d24ae32 commit 6a5440e

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

components/server/src/workspace/gitpod-server-impl.ts

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,12 +2934,11 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
29342934
organizationId: entry.organizationId,
29352935
};
29362936

2937-
let team = await this.getTeam(ctx, newProvider.organizationId || "");
2938-
if (!team) {
2937+
if (!newProvider.organizationId || !uuidValidate(newProvider.organizationId)) {
29392938
throw new ResponseError(ErrorCodes.BAD_REQUEST, "Invalid organizationId");
29402939
}
29412940

2942-
await this.guardWithFeatureFlag("orgGitAuthProviders", team);
2941+
await this.guardWithFeatureFlag("orgGitAuthProviders", newProvider.organizationId);
29432942

29442943
if (!newProvider.host) {
29452944
throw new ResponseError(
@@ -2948,6 +2947,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
29482947
);
29492948
}
29502949

2950+
// Ensure user can perform this operation on this organization
29512951
await this.guardTeamOperation(newProvider.organizationId, "create");
29522952

29532953
try {
@@ -2991,12 +2991,11 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
29912991
organizationId: entry.organizationId,
29922992
};
29932993

2994-
const team = await this.getTeam(ctx, providerUpdate.organizationId || "");
2995-
if (!team) {
2994+
if (!providerUpdate.organizationId || !uuidValidate(providerUpdate.organizationId)) {
29962995
throw new ResponseError(ErrorCodes.BAD_REQUEST, "Invalid organizationId");
29972996
}
29982997

2999-
await this.guardWithFeatureFlag("orgGitAuthProviders", team);
2998+
await this.guardWithFeatureFlag("orgGitAuthProviders", providerUpdate.organizationId);
30002999

30013000
await this.guardTeamOperation(providerUpdate.organizationId, "update");
30023001

@@ -3017,17 +3016,12 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
30173016

30183017
this.checkAndBlockUser("getOrgAuthProviders");
30193018

3020-
const team = await this.getTeam(ctx, params.organizationId || "");
3021-
if (!team) {
3022-
throw new ResponseError(ErrorCodes.BAD_REQUEST, "Invalid organizationId");
3023-
}
3024-
3025-
await this.guardWithFeatureFlag("orgGitAuthProviders", team);
3019+
await this.guardWithFeatureFlag("orgGitAuthProviders", params.organizationId);
30263020

3027-
await this.guardTeamOperation(team.id, "get");
3021+
await this.guardTeamOperation(params.organizationId, "get");
30283022

30293023
try {
3030-
const result = await this.authProviderService.getAuthProvidersOfOrg(team.id);
3024+
const result = await this.authProviderService.getAuthProvidersOfOrg(params.organizationId);
30313025
return result.map(AuthProviderEntry.redact.bind(AuthProviderEntry));
30323026
} catch (error) {
30333027
const message =
@@ -3046,7 +3040,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
30463040
throw new ResponseError(ErrorCodes.BAD_REQUEST, "Invalid organizationId");
30473041
}
30483042

3049-
await this.guardWithFeatureFlag("orgGitAuthProviders", team);
3043+
await this.guardWithFeatureFlag("orgGitAuthProviders", team.id);
30503044

30513045
// Find the matching auth provider we're attempting to delete
30523046
const orgProviders = await this.authProviderService.getAuthProvidersOfOrg(team.id);
@@ -3065,12 +3059,11 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
30653059
}
30663060
}
30673061

3068-
protected async guardWithFeatureFlag(flagName: string, team: Team) {
3062+
protected async guardWithFeatureFlag(flagName: string, teamId: string) {
30693063
// Guard method w/ a feature flag check
30703064
const isEnabled = await this.configCatClientFactory().getValueAsync(flagName, false, {
30713065
user: this.user,
3072-
teamId: team.id,
3073-
teamName: team.name,
3066+
teamId,
30743067
});
30753068
if (!isEnabled) {
30763069
throw new ResponseError(ErrorCodes.NOT_FOUND, "Method not available");

0 commit comments

Comments
 (0)