Skip to content

Commit

Permalink
manager access check in file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
katerina20 committed Jan 31, 2024
1 parent 67862cb commit 4fc7743
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.crowdin.cli.commands.NewAction;
import com.crowdin.cli.commands.Outputter;
import com.crowdin.cli.commands.functionality.*;
import com.crowdin.cli.properties.FileBean;
import com.crowdin.cli.properties.ProjectProperties;
import com.crowdin.cli.utils.PlaceholderUtil;
import com.crowdin.cli.utils.Utils;
Expand Down Expand Up @@ -47,6 +48,16 @@ class FileUploadAction implements NewAction<ProjectProperties, ProjectClient> {
public void act(Outputter out, ProjectProperties properties, ProjectClient client) {
CrowdinProjectFull project = ConsoleSpinner.execute(out, "message.spinner.fetching_project_info", "error.collect_project_info",
this.plainView, this.plainView, client::downloadFullProject);

if (!project.isManagerAccess()) {
if (!plainView) {
out.println(WARNING.withIcon(RESOURCE_BUNDLE.getString("message.no_manager_access")));
return;
} else {
throw new RuntimeException(RESOURCE_BUNDLE.getString("message.no_manager_access"));
}
}

PlaceholderUtil placeholderUtil = new PlaceholderUtil(project.getSupportedLanguages(), project.getProjectLanguages(false), properties.getBasePath());

Optional<List<Long>> attachLabelIds = Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ public void act(Outputter out, ProjectProperties properties, ProjectClient clien
CrowdinProjectFull project = ConsoleSpinner.execute(out, "message.spinner.fetching_project_info", "error.collect_project_info",
this.plainView, this.plainView, () -> client.downloadFullProject(branchName));

if (!project.isManagerAccess()) {
if (!plainView) {
out.println(WARNING.withIcon(RESOURCE_BUNDLE.getString("message.no_manager_access")));
return;
} else {
throw new RuntimeException(RESOURCE_BUNDLE.getString("message.no_manager_access"));
}
}

if (!project.findLanguageById(languageId, true).isPresent()) {
throw new RuntimeException(String.format(RESOURCE_BUNDLE.getString("error.language_not_exist"), languageId));
}
Expand Down

0 comments on commit 4fc7743

Please sign in to comment.