bdb3ca856f
- New config/credential_store.go: persistent credential storage (credentials.json) - New API: CRUD for DNS credentials + credential-types endpoint - Certificate model now supports credential_id reference - Create certificate auto-resolves credential_id to DNS config - New Vue page: Credentials.vue for managing saved DNS keys - CertCreate.vue: select existing credential or manual input + save as new - Secrets masked in API responses, never exposed in list
73 lines
1.7 KiB
TypeScript
73 lines
1.7 KiB
TypeScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
import Dashboard from '../views/Dashboard.vue'
|
|
import CertList from '../views/CertList.vue'
|
|
import CertCreate from '../views/CertCreate.vue'
|
|
import NotifyConfig from '../views/NotifyConfig.vue'
|
|
import Credentials from '../views/Credentials.vue'
|
|
import Login from '../views/Login.vue'
|
|
import { isLoggedIn } from '../api'
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes: [
|
|
{
|
|
path: '/login',
|
|
name: 'Login',
|
|
component: Login,
|
|
meta: { requiresAuth: false },
|
|
},
|
|
{
|
|
path: '/',
|
|
name: 'Dashboard',
|
|
component: Dashboard,
|
|
meta: { requiresAuth: true },
|
|
},
|
|
{
|
|
path: '/certificates',
|
|
name: 'CertList',
|
|
component: CertList,
|
|
meta: { requiresAuth: true },
|
|
},
|
|
{
|
|
path: '/create',
|
|
name: 'CertCreate',
|
|
component: CertCreate,
|
|
meta: { requiresAuth: true },
|
|
},
|
|
{
|
|
path: '/notify',
|
|
name: 'NotifyConfig',
|
|
component: NotifyConfig,
|
|
meta: { requiresAuth: true },
|
|
},
|
|
{
|
|
path: '/credentials',
|
|
name: 'Credentials',
|
|
component: Credentials,
|
|
meta: { requiresAuth: true },
|
|
},
|
|
],
|
|
})
|
|
|
|
// Navigation guard
|
|
router.beforeEach((to, _, next) => {
|
|
const requiresAuth = to.meta.requiresAuth !== false
|
|
|
|
if (requiresAuth) {
|
|
if (isLoggedIn()) {
|
|
next()
|
|
} else {
|
|
next({ name: 'Login', query: { redirect: to.fullPath } })
|
|
}
|
|
} else {
|
|
// If already logged in and going to login, redirect to dashboard
|
|
if (to.name === 'Login' && isLoggedIn()) {
|
|
next({ name: 'Dashboard' })
|
|
} else {
|
|
next()
|
|
}
|
|
}
|
|
})
|
|
|
|
export default router
|