Skip to content

Commit

Permalink
🔒: prevent anonymous user to create or import a workflow and redirect…
Browse files Browse the repository at this point in the history
… to login
  • Loading branch information
itisAliRH committed Mar 18, 2024
1 parent 64fc05d commit 36236ad
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
33 changes: 29 additions & 4 deletions client/src/components/Workflow/WorkflowListActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,35 @@ import { library } from "@fortawesome/fontawesome-svg-core";
import { faPlus, faUpload } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { BButton } from "bootstrap-vue";
import { storeToRefs } from "pinia";
import { computed } from "vue";
import { useRouter } from "vue-router/composables";
import { useUserStore } from "@/stores/userStore";
library.add(faPlus, faUpload);
const router = useRouter();
const userStore = useUserStore();
const { isAnonymous } = storeToRefs(userStore);
const createButtonTitle = computed(() => {
if (isAnonymous.value) {
return "Log in to create workflow";
} else {
return "Create new workflow";
}
});
const importButtonTitle = computed(() => {
if (isAnonymous.value) {
return "Log in to import workflow";
} else {
return "Import workflow from URL or file";
}
});
function navigateToImport() {
router.push("/workflows/import");
}
Expand All @@ -23,21 +46,23 @@ function navigateToOldCreate() {
<div>
<BButton
id="workflow-create"
v-b-tooltip.hover
v-b-tooltip.hover.noninteractive
size="sm"
title="Create new workflow"
:title="createButtonTitle"
variant="outline-primary"
:disabled="isAnonymous"
@click="navigateToOldCreate">
<FontAwesomeIcon :icon="faPlus" />
Create
</BButton>

<BButton
id="workflow-import"
v-b-tooltip.hover
v-b-tooltip.hover.noninteractive
size="sm"
title="Import workflow from URL or file"
:title="importButtonTitle"
variant="outline-primary"
:disabled="isAnonymous"
@click="navigateToImport">
<FontAwesomeIcon :icon="faUpload" />
Import
Expand Down
7 changes: 6 additions & 1 deletion client/src/entry/analysis/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ export function getRouter(Galaxy) {
}),
},
/** Workflow editor */
{ path: "/workflows/edit", component: WorkflowEditorModule },
{
path: "/workflows/edit",
component: WorkflowEditorModule,
redirect: redirectAnon(),
},
/** Published resources routes */
{
path: "/published/history",
Expand Down Expand Up @@ -521,6 +525,7 @@ export function getRouter(Galaxy) {
{
path: "workflows/import",
component: WorkflowImport,
redirect: redirectAnon(),
},
{
path: "workflows/invocations",
Expand Down

0 comments on commit 36236ad

Please sign in to comment.