新增功能: - 支持 Google Authenticator 等应用进行 TOTP 二次验证 - 用户可在个人设置中启用/禁用 2FA - 登录时支持 TOTP 验证流程 - 管理后台可全局开关 TOTP 功能 安全增强: - TOTP 密钥使用 AES-256-GCM 加密存储 - 添加 TOTP_ENCRYPTION_KEY 配置项,必须手动配置才能启用功能 - 防止服务重启导致加密密钥变更使用户无法登录 - 验证失败次数限制,防止暴力破解 配置说明: - Docker 部署:在 .env 中设置 TOTP_ENCRYPTION_KEY - 非 Docker 部署:在 config.yaml 中设置 totp.encryption_key - 生成密钥命令:openssl rand -hex 32
43 lines
2.9 KiB
Vue
43 lines
2.9 KiB
Vue
<template>
|
|
<AppLayout>
|
|
<div class="mx-auto max-w-4xl space-y-6">
|
|
<div class="grid grid-cols-1 gap-6 sm:grid-cols-3">
|
|
<StatCard :title="t('profile.accountBalance')" :value="formatCurrency(user?.balance || 0)" :icon="WalletIcon" icon-variant="success" />
|
|
<StatCard :title="t('profile.concurrencyLimit')" :value="user?.concurrency || 0" :icon="BoltIcon" icon-variant="warning" />
|
|
<StatCard :title="t('profile.memberSince')" :value="formatDate(user?.created_at || '', { year: 'numeric', month: 'long' })" :icon="CalendarIcon" icon-variant="primary" />
|
|
</div>
|
|
<ProfileInfoCard :user="user" />
|
|
<div v-if="contactInfo" class="card border-primary-200 bg-primary-50 dark:bg-primary-900/20 p-6">
|
|
<div class="flex items-center gap-4">
|
|
<div class="p-3 bg-primary-100 rounded-xl text-primary-600"><Icon name="chat" size="lg" /></div>
|
|
<div><h3 class="font-semibold text-primary-800 dark:text-primary-200">{{ t('common.contactSupport') }}</h3><p class="text-sm font-medium">{{ contactInfo }}</p></div>
|
|
</div>
|
|
</div>
|
|
<ProfileEditForm :initial-username="user?.username || ''" />
|
|
<ProfilePasswordForm />
|
|
<ProfileTotpCard />
|
|
</div>
|
|
</AppLayout>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, computed, h, onMounted } from 'vue'; import { useI18n } from 'vue-i18n'
|
|
import { useAuthStore } from '@/stores/auth'; import { formatDate } from '@/utils/format'
|
|
import { authAPI } from '@/api'; import AppLayout from '@/components/layout/AppLayout.vue'
|
|
import StatCard from '@/components/common/StatCard.vue'
|
|
import ProfileInfoCard from '@/components/user/profile/ProfileInfoCard.vue'
|
|
import ProfileEditForm from '@/components/user/profile/ProfileEditForm.vue'
|
|
import ProfilePasswordForm from '@/components/user/profile/ProfilePasswordForm.vue'
|
|
import ProfileTotpCard from '@/components/user/profile/ProfileTotpCard.vue'
|
|
import { Icon } from '@/components/icons'
|
|
|
|
const { t } = useI18n(); const authStore = useAuthStore(); const user = computed(() => authStore.user)
|
|
const contactInfo = ref('')
|
|
|
|
const WalletIcon = { render: () => h('svg', { fill: 'none', viewBox: '0 0 24 24', stroke: 'currentColor', 'stroke-width': '1.5' }, [h('path', { d: 'M21 12a2.25 2.25 0 00-2.25-2.25H15a3 3 0 11-6 0H5.25A2.25 2.25 0 003 12' })]) }
|
|
const BoltIcon = { render: () => h('svg', { fill: 'none', viewBox: '0 0 24 24', stroke: 'currentColor', 'stroke-width': '1.5' }, [h('path', { d: 'm3.75 13.5 10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z' })]) }
|
|
const CalendarIcon = { render: () => h('svg', { fill: 'none', viewBox: '0 0 24 24', stroke: 'currentColor', 'stroke-width': '1.5' }, [h('path', { d: 'M6.75 3v2.25M17.25 3v2.25' })]) }
|
|
|
|
onMounted(async () => { try { const s = await authAPI.getPublicSettings(); contactInfo.value = s.contact_info || '' } catch (error) { console.error('Failed to load contact info:', error) } })
|
|
const formatCurrency = (v: number) => `$${v.toFixed(2)}`
|
|
</script> |