From 3f3e36e6536d0a7143f0e08efefa3a10958b5741 Mon Sep 17 00:00:00 2001 From: fanyang Date: Sun, 5 Apr 2026 16:16:33 +0800 Subject: [PATCH] feat(web): warn on default-password accounts Track built-in admin and user accounts that still use their seeded password so the web UI can prompt operators to rotate credentials after deployment. - Persist must-change-password state for seeded accounts. - Clear the reminder after password changes and validate empty-password updates. - Keep the migration and auth API behavior explicit. --- easytier-web/frontend-lib/src/locales/cn.yaml | 4 + easytier-web/frontend-lib/src/locales/en.yaml | 4 + .../src/components/ChangePassword.vue | 49 ++++++- .../frontend/src/components/Login.vue | 2 + .../frontend/src/components/MainPage.vue | 60 +++++++-- easytier-web/frontend/src/modules/api.ts | 44 +++--- .../frontend/src/modules/auth-status.ts | 18 +++ easytier-web/src/db/entity/users.rs | 1 + easytier-web/src/db/mod.rs | 24 +++- ...0260405_000003_add_must_change_password.rs | 60 +++++++++ easytier-web/src/migrator/mod.rs | 2 + easytier-web/src/restful/auth.rs | 43 +++--- easytier-web/src/restful/users.rs | 127 +++++++++++++++++- 13 files changed, 382 insertions(+), 56 deletions(-) create mode 100644 easytier-web/frontend/src/modules/auth-status.ts create mode 100644 easytier-web/src/migrator/m20260405_000003_add_must_change_password.rs diff --git a/easytier-web/frontend-lib/src/locales/cn.yaml b/easytier-web/frontend-lib/src/locales/cn.yaml index b9e03753..9f3751b2 100644 --- a/easytier-web/frontend-lib/src/locales/cn.yaml +++ b/easytier-web/frontend-lib/src/locales/cn.yaml @@ -286,6 +286,9 @@ web: logout: 退出登录 language: 语言 change_password: 修改密码 + change_password_now: 立即修改密码 + default_password_warning: 当前账号仍在使用系统默认密码。为保障安全,请部署完成后立即修改密码。 + password_changed_relogin: 密码已修改,请重新登录。 device: list: 设备列表 @@ -369,6 +372,7 @@ web: change_password: 修改密码 old_password: 旧密码 new_password: 新密码 + new_password_empty: 新密码不能为空 confirm_password: 确认新密码 language: 语言 theme: 主题 diff --git a/easytier-web/frontend-lib/src/locales/en.yaml b/easytier-web/frontend-lib/src/locales/en.yaml index c614d50c..ebbc361b 100644 --- a/easytier-web/frontend-lib/src/locales/en.yaml +++ b/easytier-web/frontend-lib/src/locales/en.yaml @@ -286,6 +286,9 @@ web: logout: Logout language: Language change_password: Change Password + change_password_now: Change Password Now + default_password_warning: This account is still using the default password. Change it immediately after deployment to keep your instance secure. + password_changed_relogin: Password changed. Please log in again. device: list: Device List @@ -369,6 +372,7 @@ web: change_password: Change Password old_password: Old Password new_password: New Password + new_password_empty: New password cannot be empty confirm_password: Confirm New Password language: Language theme: Theme diff --git a/easytier-web/frontend/src/components/ChangePassword.vue b/easytier-web/frontend/src/components/ChangePassword.vue index c90a16e6..29f1be60 100644 --- a/easytier-web/frontend/src/components/ChangePassword.vue +++ b/easytier-web/frontend/src/components/ChangePassword.vue @@ -1,17 +1,52 @@ @@ -19,15 +54,17 @@ const changePassword = async () => {
- \ No newline at end of file + diff --git a/easytier-web/frontend/src/components/Login.vue b/easytier-web/frontend/src/components/Login.vue index a6f05fc0..5dd33135 100644 --- a/easytier-web/frontend/src/components/Login.vue +++ b/easytier-web/frontend/src/components/Login.vue @@ -7,6 +7,7 @@ import { I18nUtils } from 'easytier-frontend-lib'; import { getInitialApiHost, cleanAndLoadApiHosts, saveApiHost } from "../modules/api-host" import { useI18n } from 'vue-i18n' import ApiClient, { Credential, RegisterData } from '../modules/api'; +import { setMustChangePasswordFlag } from '../modules/auth-status'; const { t } = useI18n() @@ -33,6 +34,7 @@ const onSubmit = async () => { let ret = await api.value?.login(credential); if (ret.success) { localStorage.setItem('apiHost', btoa(apiHost.value)); + setMustChangePasswordFlag(Boolean(ret.mustChangePassword)); router.push({ name: 'dashboard', params: { apiHost: btoa(apiHost.value) }, diff --git a/easytier-web/frontend/src/components/MainPage.vue b/easytier-web/frontend/src/components/MainPage.vue index 0b5a335f..b56367a0 100644 --- a/easytier-web/frontend/src/components/MainPage.vue +++ b/easytier-web/frontend/src/components/MainPage.vue @@ -1,13 +1,18 @@