@enlt-bakusoku/nuxt4 0.0.0-stage → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -2
- package/dist/module.d.mts +25 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +208 -0
- package/dist/runtime/shared/schemas/user.d.ts +40 -0
- package/dist/runtime/shared/schemas/user.js +21 -0
- package/dist/runtime/tasks-catalog.d.ts +6 -0
- package/dist/runtime/tasks-catalog.js +7 -0
- package/dist/types.d.mts +9 -0
- package/package.json +120 -3
- package/scripts/bakusoku-dev.mjs +387 -0
- package/scripts/dev-log-relay.mjs +96 -0
- package/scripts/predeploy.mjs +24 -0
- package/scripts/prepare-firebase-artifact.mjs +43 -0
- package/scripts/setup-worktree.sh +59 -0
- package/scripts/verify-firebase-artifacts.mjs +70 -0
- package/src/layer/app/components/admin/AdminExecutionHistory.vue +137 -0
- package/src/layer/app/components/admin/TaskRunDialog.vue +162 -0
- package/src/layer/app/components/admin/UserManagementPage.vue +342 -0
- package/src/layer/app/components/debug/DebugApplicationLogs.vue +87 -0
- package/src/layer/app/components/debug/DebugErrorLogs.vue +47 -0
- package/src/layer/app/components/debug/DebugFirestoreOperations.vue +48 -0
- package/src/layer/app/components/debug/DebugHttpRequests.vue +86 -0
- package/src/layer/app/components/debug/DebugNavigation.vue +60 -0
- package/src/layer/app/components/debug/DebugNowControl.vue +243 -0
- package/src/layer/app/components/debug/DebugPublicConfig.vue +24 -0
- package/src/layer/app/components/debug/DebugTestAdmin.vue +67 -0
- package/src/layer/app/components/demo/DemoDebug.vue +266 -0
- package/src/layer/app/components/demo/DemoHome.vue +347 -0
- package/src/layer/app/components/demo/DemoLogin.vue +391 -0
- package/src/layer/app/components/demo/DemoPassword.vue +224 -0
- package/src/layer/app/components/demo/DemoRegister.vue +148 -0
- package/src/layer/app/components/home/HomePage.vue +77 -0
- package/src/layer/app/layouts/dashboard.vue +126 -0
- package/src/layer/app/layouts/default.vue +3 -0
- package/src/layer/app/middleware/admin.ts +15 -0
- package/src/layer/app/middleware/authenticated.ts +19 -0
- package/src/layer/app/pages/admin/migrations.vue +463 -0
- package/src/layer/app/pages/admin/tasks/[id].vue +276 -0
- package/src/layer/app/pages/admin/tasks/index.vue +220 -0
- package/src/layer/app/pages/admin/users.vue +17 -0
- package/src/layer/app/pages/bakusoku-devtools.vue +294 -0
- package/src/layer/app/plugins/auth-init.ts +36 -0
- package/src/layer/app/plugins/debug-devtools.client.ts +20 -0
- package/src/layer/app/plugins/debug-errors.client.ts +78 -0
- package/src/layer/app/plugins/debug-http.client.ts +154 -0
- package/src/layer/app/plugins/debug-nav.client.ts +28 -0
- package/src/layer/app/plugins/vuefire-inspect.ts +18 -0
- package/src/layer/app/stores/auth.ts +462 -0
- package/src/layer/app/stores/datetime.ts +41 -0
- package/src/layer/app/stores/debug.ts +235 -0
- package/src/layer/app/stores/user.ts +170 -0
- package/src/layer/app/utils/admin-execution.ts +48 -0
- package/src/layer/app/utils/dashboard-heading.ts +36 -0
- package/src/layer/app/utils/debug-bridge.ts +270 -0
- package/src/layer/app/utils/debug-firestore.ts +38 -0
- package/src/layer/app/utils/debug-format.ts +19 -0
- package/src/layer/app/utils/execution-refresh.ts +66 -0
- package/src/layer/app/utils/framework-version.ts +4 -0
- package/src/layer/app/utils/inspect-nuxt-vuefire.ts +288 -0
- package/src/layer/app/utils/is-debug-enabled.ts +13 -0
- package/src/layer/app/utils/logger.ts +235 -0
- package/src/layer/app/utils/map-auth-error.ts +11 -0
- package/src/layer/app/utils/mask-secrets.ts +100 -0
- package/src/layer/app/utils/resolve-auth-user.ts +53 -0
- package/src/layer/app/utils/resolve-firestore.ts +20 -0
- package/src/layer/app/utils/task-run.ts +15 -0
- package/src/layer/build-credentials.mjs +33 -0
- package/src/layer/nuxt.config.ts +86 -0
- package/src/layer/package.json +5 -0
- package/src/layer/server/api/debug/test-admin.post.ts +38 -0
- package/src/layer/server/api/tasks/executions/cancel.post.ts +21 -0
- package/src/layer/server/api/tasks/executions/index.get.ts +22 -0
- package/src/layer/server/api/tasks/executions/index.post.ts +25 -0
- package/src/layer/server/api/tasks/index.get.ts +70 -0
- package/src/layer/server/api/tasks/migrations/index.post.ts +27 -0
- package/src/layer/server/api/tasks/migrations/recovery.post.ts +20 -0
- package/src/layer/server/api/users/[id].delete.ts +57 -0
- package/src/layer/server/api/users/[id].put.ts +110 -0
- package/src/layer/server/api/users/index.post.ts +232 -0
- package/src/layer/server/utils/admin-access.ts +32 -0
- package/src/layer/server/utils/debug-test-admin.ts +17 -0
- package/src/layer/server/utils/firebase-admin.ts +22 -0
- package/src/layer/server/utils/logger.ts +172 -0
- package/src/layer/server/utils/tasks-gateway.ts +57 -0
- package/src/layer/server/utils/user-mutations.ts +103 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<UPage class="p-4 md:p-6 lg:p-8">
|
|
3
|
+
<UPageHeader
|
|
4
|
+
title="ユーザー作成"
|
|
5
|
+
description="新規アカウントを作成します"
|
|
6
|
+
/>
|
|
7
|
+
<UPageBody>
|
|
8
|
+
<div class="max-w-md mx-auto">
|
|
9
|
+
<UCard>
|
|
10
|
+
<UAuthForm
|
|
11
|
+
ref="createUserForm"
|
|
12
|
+
:fields="createUserFields"
|
|
13
|
+
:validate="validateCreateUser"
|
|
14
|
+
:loading="isLoading"
|
|
15
|
+
:disabled="isLoading"
|
|
16
|
+
title="ユーザー作成"
|
|
17
|
+
description="メールアドレス、表示名、パスワードを入力してください。"
|
|
18
|
+
icon="i-heroicons-user-plus"
|
|
19
|
+
:submit="{ label: 'ユーザーを作成', block: true, color: 'primary' }"
|
|
20
|
+
@submit="handleCreateUser"
|
|
21
|
+
>
|
|
22
|
+
<template #validation>
|
|
23
|
+
<UAlert
|
|
24
|
+
v-if="userStore.error"
|
|
25
|
+
color="error"
|
|
26
|
+
variant="soft"
|
|
27
|
+
:title="userStore.error"
|
|
28
|
+
/>
|
|
29
|
+
</template>
|
|
30
|
+
</UAuthForm>
|
|
31
|
+
</UCard>
|
|
32
|
+
|
|
33
|
+
<p class="mt-6 text-center text-sm text-gray-500 dark:text-gray-400">
|
|
34
|
+
既にアカウントをお持ちの方は
|
|
35
|
+
<NuxtLink to="/login" class="text-primary-500 hover:underline">
|
|
36
|
+
ログイン
|
|
37
|
+
</NuxtLink>
|
|
38
|
+
</p>
|
|
39
|
+
</div>
|
|
40
|
+
</UPageBody>
|
|
41
|
+
</UPage>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script setup lang="ts">
|
|
45
|
+
import { useBakusokuAuthStore } from '../../stores/auth'
|
|
46
|
+
import { useBakusokuUserStore } from '../../stores/user'
|
|
47
|
+
|
|
48
|
+
import type { AuthFormField, FormError, FormSubmitEvent } from '@nuxt/ui'
|
|
49
|
+
import { createUserSchema, type CreateUserInput } from '#bakusoku/user-schemas'
|
|
50
|
+
|
|
51
|
+
const authStore = useBakusokuAuthStore()
|
|
52
|
+
const userStore = useBakusokuUserStore()
|
|
53
|
+
const toast = useToast()
|
|
54
|
+
const router = useRouter()
|
|
55
|
+
const isLoading = ref(false)
|
|
56
|
+
const createUserFormRef = useTemplateRef<{ state: { email: string; displayName: string; password: string } }>('createUserForm')
|
|
57
|
+
|
|
58
|
+
const createUserFields: AuthFormField[] = [
|
|
59
|
+
{
|
|
60
|
+
name: 'email',
|
|
61
|
+
type: 'email',
|
|
62
|
+
label: 'メールアドレス',
|
|
63
|
+
placeholder: 'メールアドレスを入力',
|
|
64
|
+
required: true,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'displayName',
|
|
68
|
+
type: 'text',
|
|
69
|
+
label: '表示名',
|
|
70
|
+
placeholder: '表示名を入力',
|
|
71
|
+
required: true,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'password',
|
|
75
|
+
type: 'password',
|
|
76
|
+
label: 'パスワード',
|
|
77
|
+
placeholder: 'パスワードを入力(6文字以上)',
|
|
78
|
+
required: true,
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Zodスキーマを使用したバリデーション関数
|
|
84
|
+
*/
|
|
85
|
+
function validateCreateUser(state: Partial<CreateUserInput>): FormError[] {
|
|
86
|
+
// Zodスキーマでバリデーション(部分的な値でもチェック可能)
|
|
87
|
+
const result = createUserSchema.safeParse(state)
|
|
88
|
+
|
|
89
|
+
if (result.success) {
|
|
90
|
+
return []
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ZodのエラーをFormError形式に変換
|
|
94
|
+
const errors: FormError[] = result.error.issues.map((issue) => {
|
|
95
|
+
// パスの最初の要素をフィールド名として使用
|
|
96
|
+
const fieldName = issue.path[0] as string
|
|
97
|
+
return {
|
|
98
|
+
name: fieldName,
|
|
99
|
+
message: issue.message,
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
return errors
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** 登録フォームの内容でユーザーを作成し、結果を画面に反映する。 */
|
|
107
|
+
async function handleCreateUser(event: FormSubmitEvent<CreateUserInput>) {
|
|
108
|
+
isLoading.value = true
|
|
109
|
+
try {
|
|
110
|
+
await userStore.createUser({
|
|
111
|
+
email: event.data.email,
|
|
112
|
+
displayName: event.data.displayName,
|
|
113
|
+
password: event.data.password,
|
|
114
|
+
role: 'user',
|
|
115
|
+
})
|
|
116
|
+
let verificationSent = false
|
|
117
|
+
try {
|
|
118
|
+
await authStore.login(event.data.email, event.data.password)
|
|
119
|
+
} catch {
|
|
120
|
+
verificationSent = authStore.error?.includes('確認メールを送信しました') === true
|
|
121
|
+
if (!verificationSent) throw new Error(authStore.error ?? '確認メールを送信できませんでした。')
|
|
122
|
+
}
|
|
123
|
+
toast.add({
|
|
124
|
+
title: verificationSent ? '確認メールを送信しました' : 'ユーザーを作成しました',
|
|
125
|
+
description: verificationSent
|
|
126
|
+
? 'メールのリンクを開いてからログインしてください。'
|
|
127
|
+
: 'ログインページからログインしてください。',
|
|
128
|
+
color: 'success',
|
|
129
|
+
})
|
|
130
|
+
const state = createUserFormRef.value?.state
|
|
131
|
+
if (state) {
|
|
132
|
+
state.email = ''
|
|
133
|
+
state.displayName = ''
|
|
134
|
+
state.password = ''
|
|
135
|
+
}
|
|
136
|
+
await router.push('/login')
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.error('ユーザー作成エラー:', error)
|
|
139
|
+
toast.add({
|
|
140
|
+
title: 'ユーザー作成に失敗しました',
|
|
141
|
+
description: userStore.error ?? (error as Error).message,
|
|
142
|
+
color: 'error',
|
|
143
|
+
})
|
|
144
|
+
} finally {
|
|
145
|
+
isLoading.value = false
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
</script>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<UPage class="p-4 md:p-6 lg:p-8">
|
|
3
|
+
<UPageHeader
|
|
4
|
+
title="ようこそ"
|
|
5
|
+
description="ここからアプリケーションの開発を始めましょう。"
|
|
6
|
+
/>
|
|
7
|
+
<UPageBody>
|
|
8
|
+
<div class="max-w-2xl mx-auto">
|
|
9
|
+
<!-- ローディング状態 -->
|
|
10
|
+
<UCard v-if="isLoading" class="text-center py-12">
|
|
11
|
+
<div class="flex flex-col items-center gap-4">
|
|
12
|
+
<UIcon name="i-heroicons-arrow-path" class="w-10 h-10 animate-spin text-primary-500" />
|
|
13
|
+
<p class="text-gray-600 dark:text-gray-400">読み込み中...</p>
|
|
14
|
+
</div>
|
|
15
|
+
</UCard>
|
|
16
|
+
|
|
17
|
+
<!-- ログイン済み状態 -->
|
|
18
|
+
<div v-else class="space-y-6">
|
|
19
|
+
<UCard>
|
|
20
|
+
<template #header>
|
|
21
|
+
<h2 class="text-2xl font-semibold">ユーザー情報</h2>
|
|
22
|
+
</template>
|
|
23
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
24
|
+
<div class="space-y-1">
|
|
25
|
+
<p class="text-sm font-medium text-gray-500 dark:text-gray-400">表示名</p>
|
|
26
|
+
<p class="text-lg font-semibold">{{ authStore.user?.displayName || '未設定' }}</p>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="space-y-1">
|
|
29
|
+
<p class="text-sm font-medium text-gray-500 dark:text-gray-400">メールアドレス</p>
|
|
30
|
+
<p class="text-lg font-semibold">{{ authStore.user?.email || '未設定' }}</p>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
</div>
|
|
34
|
+
<template #footer>
|
|
35
|
+
<div class="flex justify-end gap-2">
|
|
36
|
+
<UButton
|
|
37
|
+
color="error"
|
|
38
|
+
variant="outline"
|
|
39
|
+
@click="handleLogout"
|
|
40
|
+
>
|
|
41
|
+
ログアウト
|
|
42
|
+
</UButton>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
45
|
+
</UCard>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</UPageBody>
|
|
49
|
+
</UPage>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script setup lang="ts">
|
|
53
|
+
import { useBakusokuAuthStore } from '../../stores/auth'
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
import { ref } from '#imports'
|
|
57
|
+
|
|
58
|
+
// 認証情報
|
|
59
|
+
const authStore = useBakusokuAuthStore()
|
|
60
|
+
// ローディング状態
|
|
61
|
+
const isLoading = ref(false)
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* ログアウト
|
|
65
|
+
*/
|
|
66
|
+
const handleLogout = async () => {
|
|
67
|
+
isLoading.value = true
|
|
68
|
+
try {
|
|
69
|
+
await authStore.logout()
|
|
70
|
+
await navigateTo('/login')
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error('ログアウトエラー:', error)
|
|
73
|
+
} finally {
|
|
74
|
+
isLoading.value = false
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
</script>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<UDashboardGroup unit="rem">
|
|
3
|
+
<UDashboardSidebar
|
|
4
|
+
id="bakusoku"
|
|
5
|
+
:default-size="16"
|
|
6
|
+
:min-size="14"
|
|
7
|
+
:max-size="22"
|
|
8
|
+
:ui="{ footer: 'border-t border-default' }"
|
|
9
|
+
>
|
|
10
|
+
<template #header>
|
|
11
|
+
<NuxtLink to="/" class="flex min-w-0 items-center gap-2 font-semibold text-highlighted">
|
|
12
|
+
<UIcon name="i-lucide-zap" class="size-5 shrink-0 text-primary" />
|
|
13
|
+
<span class="truncate">Bakusoku</span>
|
|
14
|
+
</NuxtLink>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<template #default>
|
|
18
|
+
<UNavigationMenu
|
|
19
|
+
:items="items"
|
|
20
|
+
orientation="vertical"
|
|
21
|
+
class="w-full"
|
|
22
|
+
/>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<template #footer>
|
|
26
|
+
<div class="flex w-full items-center gap-2">
|
|
27
|
+
<UAvatar icon="i-lucide-user-round" size="sm" />
|
|
28
|
+
<div class="min-w-0 flex-1">
|
|
29
|
+
<p class="truncate text-sm font-medium">
|
|
30
|
+
{{ displayName }}
|
|
31
|
+
</p>
|
|
32
|
+
<p class="truncate text-xs text-gray-500 dark:text-gray-400">
|
|
33
|
+
{{ roleLabel }}
|
|
34
|
+
</p>
|
|
35
|
+
</div>
|
|
36
|
+
<UButton
|
|
37
|
+
icon="i-lucide-log-out"
|
|
38
|
+
color="neutral"
|
|
39
|
+
variant="ghost"
|
|
40
|
+
size="sm"
|
|
41
|
+
aria-label="ログアウト"
|
|
42
|
+
:loading="loggingOut"
|
|
43
|
+
@click="logout"
|
|
44
|
+
/>
|
|
45
|
+
<UColorModeButton />
|
|
46
|
+
</div>
|
|
47
|
+
</template>
|
|
48
|
+
</UDashboardSidebar>
|
|
49
|
+
|
|
50
|
+
<UDashboardPanel>
|
|
51
|
+
<template #header>
|
|
52
|
+
<UDashboardNavbar :title="title" />
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<template #body>
|
|
56
|
+
<p v-if="description" class="text-sm text-gray-500 dark:text-gray-400">
|
|
57
|
+
{{ description }}
|
|
58
|
+
</p>
|
|
59
|
+
<slot />
|
|
60
|
+
</template>
|
|
61
|
+
</UDashboardPanel>
|
|
62
|
+
</UDashboardGroup>
|
|
63
|
+
</template>
|
|
64
|
+
|
|
65
|
+
<script setup lang="ts">
|
|
66
|
+
import type { NavigationMenuItem } from '@nuxt/ui'
|
|
67
|
+
import { useBakusokuAuthStore } from '../stores/auth'
|
|
68
|
+
import { useDashboardHeadingState } from '../utils/dashboard-heading'
|
|
69
|
+
import { computed, navigateTo, ref, useRoute, useRuntimeConfig } from '#imports'
|
|
70
|
+
|
|
71
|
+
const authStore = useBakusokuAuthStore()
|
|
72
|
+
const route = useRoute()
|
|
73
|
+
const runtimeConfig = useRuntimeConfig()
|
|
74
|
+
const { title, description } = useDashboardHeadingState()
|
|
75
|
+
const loggingOut = ref(false)
|
|
76
|
+
|
|
77
|
+
const isAdmin = computed(() => authStore.user?.role === 'admin')
|
|
78
|
+
const tasksEnabled = computed(() => runtimeConfig.public.tasksEnabled === true)
|
|
79
|
+
|
|
80
|
+
const items = computed<NavigationMenuItem[][]>(() => {
|
|
81
|
+
const main: NavigationMenuItem[] = [
|
|
82
|
+
{ label: 'ホーム', icon: 'i-lucide-house', to: '/', exact: true },
|
|
83
|
+
]
|
|
84
|
+
if (!isAdmin.value) return [main]
|
|
85
|
+
|
|
86
|
+
const admin: NavigationMenuItem[] = [
|
|
87
|
+
{ label: '管理', type: 'label' },
|
|
88
|
+
{ label: 'ユーザー管理', icon: 'i-lucide-users', to: '/admin/users' },
|
|
89
|
+
]
|
|
90
|
+
if (tasksEnabled.value) {
|
|
91
|
+
admin.push(
|
|
92
|
+
{
|
|
93
|
+
label: 'タスク管理',
|
|
94
|
+
icon: 'i-lucide-timer',
|
|
95
|
+
to: '/admin/tasks',
|
|
96
|
+
active: route.path === '/admin/tasks' || route.path.startsWith('/admin/tasks/'),
|
|
97
|
+
},
|
|
98
|
+
{ label: 'マイグレーション管理', icon: 'i-lucide-database', to: '/admin/migrations' },
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
return [main, admin]
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
const displayName = computed(() => authStore.user?.displayName || authStore.user?.email || 'ユーザー')
|
|
105
|
+
|
|
106
|
+
const roleLabel = computed(() => {
|
|
107
|
+
const role = authStore.user?.role
|
|
108
|
+
if (role === 'admin') return '管理者'
|
|
109
|
+
if (role === 'approver') return '承認者'
|
|
110
|
+
if (role === 'user') return '一般'
|
|
111
|
+
return role || '未設定'
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
/** ログアウトしてログイン画面へ遷移する。 */
|
|
115
|
+
async function logout() {
|
|
116
|
+
loggingOut.value = true
|
|
117
|
+
try {
|
|
118
|
+
await authStore.logout()
|
|
119
|
+
await navigateTo('/login')
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.error('ログアウトエラー:', error)
|
|
122
|
+
} finally {
|
|
123
|
+
loggingOut.value = false
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
</script>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineNuxtRouteMiddleware, navigateTo } from 'nuxt/app'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* admin — admin 以外は /
|
|
5
|
+
*
|
|
6
|
+
* プロフィール同期は bakusoku-auth-init プラグインが担当。
|
|
7
|
+
*/
|
|
8
|
+
export default defineNuxtRouteMiddleware(() => {
|
|
9
|
+
const auth = useBakusokuAuthStore()
|
|
10
|
+
const profile = auth.user
|
|
11
|
+
|
|
12
|
+
if (!profile || profile.role !== 'admin' || profile.disabled === true || profile.deletionPending === true) {
|
|
13
|
+
return navigateTo({ path: '/' })
|
|
14
|
+
}
|
|
15
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defineNuxtRouteMiddleware, navigateTo } from 'nuxt/app'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* authenticated — 未認証なら /login
|
|
5
|
+
*
|
|
6
|
+
* Auth ↔ プロフィール同期は bakusoku-auth-init プラグインが担当。
|
|
7
|
+
* ここではストアの結果だけを見る。
|
|
8
|
+
*/
|
|
9
|
+
export default defineNuxtRouteMiddleware(to => {
|
|
10
|
+
const auth = useBakusokuAuthStore()
|
|
11
|
+
|
|
12
|
+
const profile = auth.user
|
|
13
|
+
if (!profile || profile.disabled === true || profile.deletionPending === true) {
|
|
14
|
+
return navigateTo({
|
|
15
|
+
path: '/login',
|
|
16
|
+
...(profile ? {} : { query: { redirect: to.fullPath } }),
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
})
|