diff --git a/frontend/src/views/LoginView.vue b/frontend/src/views/LoginView.vue index 7716a4ae..601402e8 100644 --- a/frontend/src/views/LoginView.vue +++ b/frontend/src/views/LoginView.vue @@ -3,54 +3,31 @@ MIROFISH - AUTH {{ $t('login.title') }} - {{ $t('login.subtitle') }} + {{ $t('login.accountActivated') }} + {{ $t('login.subtitle') }} - - {{ $t('login.username') }} - + {{ $t('login.email') }} + - {{ $t('login.password') }} - + - - - {{ error }} - - - + {{ error }} + {{ $t('login.loading') }} - {{ $t('login.submit') }} → + {{ $t('login.submit') }} → + {{ $t('login.forgotPassword') }} @@ -62,33 +39,29 @@ import { ref, computed } from 'vue' import { useRouter, useRoute } from 'vue-router' import { useI18n } from 'vue-i18n' import service from '../api/index' -import { setToken } from '../store/auth' +import { setAuth } from '../store/auth' const router = useRouter() const route = useRoute() const { t } = useI18n() -const form = ref({ username: '', password: '' }) +const form = ref({ email: '', password: '' }) const loading = ref(false) const error = ref('') - -const canSubmit = computed( - () => form.value.username.trim() !== '' && form.value.password !== '' -) +const activated = computed(() => route.query.activated === '1') +const canSubmit = computed(() => form.value.email.trim() !== '' && form.value.password !== '') async function handleLogin() { if (!canSubmit.value || loading.value) return loading.value = true error.value = '' - try { const res = await service.post('/api/auth/login', { - username: form.value.username, + email: form.value.email, password: form.value.password }) - setToken(res.token) - const redirect = route.query.redirect || '/' - router.push(redirect) + setAuth(res.token, res.user) + router.push(route.query.redirect || '/') } catch { error.value = t('login.invalidCredentials') } finally { @@ -98,157 +71,26 @@ async function handleLogin() { diff --git a/locales/en.json b/locales/en.json index c55e1f03..548365fc 100644 --- a/locales/en.json +++ b/locales/en.json @@ -778,11 +778,38 @@ "subtitle": "// Authenticated access required", "username": "Username", "usernamePlaceholder": "demo", + "email": "Email", + "emailPlaceholder": "your@email.com", "password": "Password", "passwordPlaceholder": "••••••••", "submit": "Enter", "loading": "Authenticating...", - "invalidCredentials": "Invalid username or password" + "invalidCredentials": "Invalid username or password", + "forgotPassword": "Forgot password?", + "accountActivated": "Account activated. You can now log in." + }, + "forgotPassword": { + "title": "Forgot Password", + "subtitle": "Enter your email and we'll send you a reset link.", + "submit": "Send reset link", + "sent": "If an account exists with this email, you will receive a reset link shortly." + }, + "resetPassword": { + "title": "Reset Password", + "newPassword": "New password", + "confirmPassword": "Confirm password", + "submit": "Set new password", + "done": "Password updated. You can now log in.", + "goToLogin": "Go to login", + "invalidToken": "This link is invalid or has expired.", + "passwordMismatch": "Passwords do not match." + }, + "setPassword": { + "title": "Welcome to MiroFish", + "newPassword": "Choose a password", + "submit": "Activate account", + "done": "Account activated! Redirecting to login...", + "invalidToken": "This invitation link is invalid or has expired." }, "error": { "filesLostAfterRefresh": "Files were lost after page refresh. Redirecting to home to re-select files…" diff --git a/locales/zh.json b/locales/zh.json index 671c772c..c6d5fa68 100644 --- a/locales/zh.json +++ b/locales/zh.json @@ -778,11 +778,38 @@ "subtitle": "// 需要身份验证", "username": "用户名", "usernamePlaceholder": "demo", + "email": "邮箱", + "emailPlaceholder": "your@email.com", "password": "密码", "passwordPlaceholder": "••••••••", "submit": "登录", "loading": "验证中...", - "invalidCredentials": "用户名或密码错误" + "invalidCredentials": "用户名或密码错误", + "forgotPassword": "忘记密码?", + "accountActivated": "账户已激活,现在可以登录。" + }, + "forgotPassword": { + "title": "忘记密码", + "subtitle": "请输入您的邮箱,我们将发送重置链接。", + "submit": "发送重置链接", + "sent": "如果该邮箱已注册,您将收到重置链接。" + }, + "resetPassword": { + "title": "重置密码", + "newPassword": "新密码", + "confirmPassword": "确认密码", + "submit": "设置新密码", + "done": "密码已更新,现在可以登录。", + "goToLogin": "前往登录", + "invalidToken": "此链接无效或已过期。", + "passwordMismatch": "两次密码不一致。" + }, + "setPassword": { + "title": "欢迎使用 MiroFish", + "newPassword": "设置密码", + "submit": "激活账户", + "done": "账户已激活!正在跳转到登录页面...", + "invalidToken": "此邀请链接无效或已过期。" }, "error": { "filesLostAfterRefresh": "刷新页面后文件丢失,正在跳转到首页重新选择文件…"
{{ $t('login.subtitle') }}
{{ $t('login.accountActivated') }}