Add default credential reset safeguards

This commit is contained in:
ekko
2026-05-24 09:49:21 +08:00
committed by ekko
parent 9708a6a521
commit f8a1b2f6ae
22 changed files with 565 additions and 7 deletions
+9 -1
View File
@@ -63,6 +63,7 @@ async function handlePasswordLogin() {
</div>
<h1 class="login-title">{{ t("login.title") }}</h1>
<p class="login-desc">{{ t("login.description") }}</p>
<p class="login-default-hint">{{ t("login.defaultCredentialsHint") }}</p>
<form class="login-form" @submit.prevent="handleLogin">
<input
@@ -128,10 +129,17 @@ async function handlePasswordLogin() {
.login-desc {
font-size: 14px;
color: $text-muted;
margin: 0 0 32px;
margin: 0 0 12px;
line-height: 1.6;
}
.login-default-hint {
margin: 0 0 28px;
font-family: $font-code;
font-size: 13px;
color: $text-secondary;
}
.login-form {
display: flex;
flex-direction: column;
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { onMounted } from "vue";
import { computed, onMounted, ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import {
NTabs,
NTabPane,
@@ -22,6 +23,41 @@ import { isStoredSuperAdmin } from "@/api/client";
const settingsStore = useSettingsStore();
const { t } = useI18n();
const canManageUsers = isStoredSuperAdmin();
const route = useRoute();
const router = useRouter();
const activeTab = ref("account");
const validTabs = computed(() => new Set([
"account",
...(canManageUsers ? ["users"] : []),
"display",
"agent",
"memory",
"compression",
"session",
"privacy",
"models",
"voice",
]));
function normalizeTab(value: unknown): string {
const tab = typeof value === "string" ? value : "";
return validTabs.value.has(tab) ? tab : "account";
}
function handleTabUpdate(tab: string) {
activeTab.value = normalizeTab(tab);
router.replace({
query: {
...route.query,
tab: activeTab.value === "account" ? undefined : activeTab.value,
},
});
}
watch(() => route.query.tab, (tab) => {
activeTab.value = normalizeTab(tab);
}, { immediate: true });
onMounted(() => {
settingsStore.fetchSettings();
@@ -40,7 +76,7 @@ onMounted(() => {
size="large"
:description="t('common.loading')"
>
<NTabs type="line" animated>
<NTabs v-model:value="activeTab" type="line" animated @update:value="handleTabUpdate">
<NTabPane name="account" :tab="t('settings.tabs.account')">
<AccountSettings />
</NTabPane>