Skip to content
Snippets Groups Projects
AuthWall.vue 682 B
Newer Older
  • Learn to ignore specific revisions
  •   <div v-if="authStore.steeringUser" class="tw-w-full">
    
    Konrad Mohrfeldt's avatar
    Konrad Mohrfeldt committed
        <slot />
      </div>
    
    Konrad Mohrfeldt's avatar
    Konrad Mohrfeldt committed
      <div v-else class="tw-w-full tw-text-center">
    
        {{ t('loading') }}
    
    Konrad Mohrfeldt's avatar
    Konrad Mohrfeldt committed
      </div>
    
    <script setup>
    import { useAuthStore } from '@/stores/auth'
    import { watchEffect } from 'vue'
    import { useRouter } from 'vue-router'
    import { useToast } from 'vue-toast-notification'
    import { useI18n } from '@/i18n'
    
    const router = useRouter()
    const authStore = useAuthStore()
    const toast = useToast()
    const { t } = useI18n()
    
    watchEffect(() => {
      if (authStore.steeringUser && !authStore.isSuperuser) {
        toast.error(t('auth.permissionError'))
        router.push({ name: 'home' })
      }
    })