mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-06 07:12:46 +01:00
fix: redirect to login (#1082)
This commit is contained in:
2
Makefile
2
Makefile
@@ -29,7 +29,7 @@ test:
|
||||
.PHONY: test-coverage
|
||||
test-coverage:
|
||||
@echo "Testing with coverage..."
|
||||
go test -coverpkg=./... -coverprofile=coverage.out ./...
|
||||
go test -coverpkg=./... -coverprofile=coverage.out -count 1 ./...
|
||||
go tool cover -func=coverage.out
|
||||
go tool cover -html=coverage.out
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -19,6 +20,8 @@ func TestWebhook_Run(t *testing.T) {
|
||||
|
||||
go http.ListenAndServe("127.0.0.1:12347", server) //nolint:gosec,errcheck
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
type fields struct {
|
||||
Headers map[string]string
|
||||
URL string
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import TanView from '@/components/TanView.vue'
|
||||
import { Button, buttonVariants } from '@/components/ui/button'
|
||||
import {
|
||||
DropdownMenu,
|
||||
@@ -13,7 +12,8 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip
|
||||
|
||||
import { CircleUser } from 'lucide-vue-next'
|
||||
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
import type { AuthModel } from 'pocketbase'
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
||||
import { pb } from '@/lib/pocketbase'
|
||||
import { cn } from '@/lib/utils'
|
||||
@@ -24,26 +24,31 @@ defineProps<{
|
||||
|
||||
const variant = 'secondary'
|
||||
|
||||
const {
|
||||
isPending,
|
||||
isError,
|
||||
data: user,
|
||||
error
|
||||
} = useQuery({
|
||||
queryKey: ['user'],
|
||||
queryFn: () => pb.authStore.model
|
||||
})
|
||||
interface User {
|
||||
name: string
|
||||
}
|
||||
|
||||
const user = ref<AuthModel | User>(pb.authStore.model)
|
||||
|
||||
const logout = () => {
|
||||
pb.authStore.clear()
|
||||
window.location.href = '/ui/login'
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
pb.collection('users')
|
||||
.authRefresh()
|
||||
.catch(() => {
|
||||
pb.authStore.clear()
|
||||
window.location.href = '/ui/login'
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TanView :is-error="isError" :is-pending="isPending" :error="error" :value="user">
|
||||
<div class="group flex flex-col gap-4 py-2 data-[collapsed=true]:py-2">
|
||||
<nav
|
||||
v-if="user"
|
||||
class="grid gap-1 px-2 group-[[data-collapsed=true]]:justify-center group-[[data-collapsed=true]]:px-2"
|
||||
>
|
||||
<DropdownMenu>
|
||||
@@ -66,9 +71,7 @@ const logout = () => {
|
||||
</Tooltip>
|
||||
<Button
|
||||
v-else
|
||||
:class="
|
||||
cn(buttonVariants({ variant: variant, size: 'sm' }), 'w-full justify-start')
|
||||
"
|
||||
:class="cn(buttonVariants({ variant: variant, size: 'sm' }), 'w-full justify-start')"
|
||||
>
|
||||
<CircleUser class="mr-2 size-4" />
|
||||
{{ user.name }}
|
||||
@@ -88,5 +91,4 @@ const logout = () => {
|
||||
</DropdownMenu>
|
||||
</nav>
|
||||
</div>
|
||||
</TanView>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user