Skip to content
Snippets Groups Projects
Verified Commit 43e39f98 authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Disable features for unauthorized user

#33
parent e1423291
No related branches found
No related tags found
2 merge requests!84Remove development branch,!28Resolve "Disable feature for foreign users"
......@@ -19,6 +19,7 @@ const props = defineProps<{
active: boolean;
bucket: BucketOut;
loading: boolean;
deletable: boolean;
}>();
const randomIDSuffix = Math.random().toString(16).substr(2, 8);
......@@ -88,7 +89,7 @@ onMounted(() => {
<span class="text-truncate" style="width: 80%">{{ bucket.name }}</span>
<div>
<bootstrap-icon
v-if="props.active && permission == null"
v-if="props.active && permission == null && props.deletable"
icon="trash-fill"
class="delete-icon me-2"
:width="16"
......
......@@ -636,6 +636,7 @@ watch(
/>
<!-- Add bucket permission button -->
<button
v-if="!authStore.foreignUser"
:hidden="bucketRepository.getBucketPermission(props.bucketName) != null"
type="button"
class="btn btn-secondary m-2 tooltip-container"
......@@ -653,6 +654,7 @@ watch(
<span class="visually-hidden">Add Bucket Permission</span>
</button>
<permission-modal
v-if="!authStore.foreignUser"
modalID="create-permission-modal"
:bucket-name="props.bucketName"
:sub-folders="folderStructure"
......@@ -666,6 +668,7 @@ watch(
"
/>
<button
v-if="!authStore.foreignUser"
:hidden="bucketRepository.getBucketPermission(props.bucketName) != null"
type="button"
class="btn btn-secondary m-2 tooltip-container"
......@@ -683,7 +686,10 @@ watch(
<span class="visually-hidden">View Bucket Permissions</span>
</button>
<permission-list-modal
v-if="bucketRepository.getBucketPermission(props.bucketName) == null"
v-if="
bucketRepository.getBucketPermission(props.bucketName) == null &&
!authStore.foreignUser
"
:bucket-name="props.bucketName"
:sub-folders="folderStructure"
modalID="permission-list-modal"
......
......@@ -69,7 +69,7 @@ onBeforeUnmount(() => {
height="24"
class="d-inline-block align-text-top me-2"
/>
S3 Proxy
CloWM
</router-link>
<button
class="navbar-toggler"
......
import { defineStore } from "pinia";
import type { User } from "@/client/auth";
import { UserService } from "@/client/auth";
import { UserService, RoleEnum } from "@/client/auth";
import { S3KeyService } from "@/client/s3proxy";
import type { S3Key } from "@/client/s3proxy";
import { OpenAPI as S3ProxyOpenAPI } from "@/client/s3proxy";
......@@ -23,6 +23,15 @@ export const useAuthStore = defineStore({
} as RootState),
getters: {
authenticated: (state) => state.token != null,
foreignUser: (state) =>
state.user?.roles?.includes(RoleEnum.FOREIGN_USER) ?? true,
normalUser: (state) => state.user?.roles?.includes(RoleEnum.USER) ?? false,
workflowReviewer: (state) =>
state.user?.roles?.includes(RoleEnum.REVIEWER) ?? false,
workflowDev: (state) =>
state.user?.roles?.includes(RoleEnum.DEVELOPER) ?? false,
workflowAdmin: (state) =>
state.user?.roles?.includes(RoleEnum.ADMINISTRATOR) ?? false,
},
actions: {
setToken(token: string | null) {
......
......@@ -52,7 +52,7 @@ export const useBucketStore = defineStore({
onFinally: (() => void) | null | undefined = null
) {
const authStore = useAuthStore();
if (authStore.user != null) {
if (authStore.user != null && !authStore.foreignUser) {
BucketPermissionService.bucketPermissionListPermissionsPerUser(
authStore.user.uid
)
......@@ -80,7 +80,8 @@ export const useBucketStore = defineStore({
onRejected: ((reason: any) => void) | null | undefined = null,
onFinally: (() => void) | null | undefined = null
) {
BucketService.bucketListBuckets()
const authStore = useAuthStore();
BucketService.bucketListBuckets(authStore.user?.uid)
.then((buckets) => {
this.buckets = buckets;
onFulfilled?.(buckets);
......
......@@ -60,7 +60,7 @@ onMounted(() => {
<div
class="card text-center bg-dark ms-md-auto position-fixed top-50 start-50 translate-middle"
>
<div class="card-header text-dark bg-light">S3Proxy</div>
<div class="card-header text-dark bg-light">CloWM</div>
<div class="card-body p-5">
<h5 class="card-title text-light">Login</h5>
<p class="card-text text-secondary">
......
......@@ -9,10 +9,12 @@ import DeleteModal from "@/components/Modals/DeleteModal.vue";
import BucketListItem from "@/components/BucketListItem.vue";
import { useBucketStore } from "@/stores/buckets";
import { Modal } from "bootstrap";
import { useAuthStore } from "@/stores/auth";
const route = useRoute();
const router = useRouter();
const bucketRepository = useBucketStore();
const authStore = useAuthStore();
const bucketsState = reactive({
filterString: "",
......@@ -58,6 +60,7 @@ onMounted(() => {
<template>
<DeleteModal
v-if="!authStore.foreignUser"
modalID="delete-bucket-modal"
:object-name-delete="bucketsState.potentialDeleteBucketName"
:back-modal-id="undefined"
......@@ -65,7 +68,10 @@ onMounted(() => {
confirmedDeleteBucket(bucketsState.potentialDeleteBucketName)
"
/>
<CreateBucketModal modalID="create-bucket-modal" />
<CreateBucketModal
modalID="create-bucket-modal"
v-if="!authStore.foreignUser"
/>
<div class="row m-2 border-bottom border-light mt-4">
<div class="col-12"></div>
<h1 class="mb-2 text-light">Buckets</h1>
......@@ -82,6 +88,7 @@ onMounted(() => {
<span class="visually-hidden">Refresh Buckets</span>
</button>
<button
v-if="!authStore.foreignUser"
type="button"
class="btn btn-light"
data-bs-toggle="modal"
......@@ -115,6 +122,7 @@ onMounted(() => {
route.params.bucketName != null &&
route.params.bucketName === bucket.name
"
:deletable="!authStore.foreignUser"
:bucket="bucket"
:loading="false"
@delete-bucket="deleteBucket"
......@@ -140,6 +148,7 @@ onMounted(() => {
:active="false"
:loading="true"
:permission="undefined"
:deletable="!authStore.foreignUser"
:bucket="{
name: '',
description: '',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment