fix(deploy): 明确提示初始管理员密码

This commit is contained in:
2026-08-25 16:22:46 +08:00
parent 8cd1fb137d
commit 7dc4313de6
8 changed files with 114 additions and 12 deletions
+27 -6
View File
@@ -358,6 +358,32 @@ function Start-Services {
Ok "EasyAI started"
}
function Show-AdminLoginInfo {
Write-Host ""
if ($script:SecurityEnvMode -ne "new") {
Write-Host " 管理员账号: admin(本次部署不会生成或重置已有密码)" -ForegroundColor Yellow
Write-Host " 登录提示: 若数据库尚未创建 admin,请查看 .env -> CONFIG_INITIAL_ADMIN_PASSWORD;若 admin 已存在,请使用当前密码。" -ForegroundColor DarkGray
return
}
$content = Get-Content (Join-Path $script:Root ".env") -Raw -Encoding UTF8
$initialAdminPassword = Get-EnvValue $content "CONFIG_INITIAL_ADMIN_PASSWORD"
if ([string]::IsNullOrWhiteSpace($initialAdminPassword)) {
Fail "Cannot read initial admin password from .env -> CONFIG_INITIAL_ADMIN_PASSWORD"
}
$heading = if ($script:DeployDryRun) {
" -------- 初始管理员(Docker 首次启动后生效)--------"
} else {
" -------- 初始管理员(首次登录后请立即修改密码)--------"
}
Write-Host $heading -ForegroundColor Yellow
Write-Host " 登录账号: " -NoNewline; Write-Host "admin" -ForegroundColor White
Write-Host " 登录密码: " -NoNewline; Write-Host $initialAdminPassword -ForegroundColor White
Write-Host " 生命周期: 仅在数据库首次创建 admin 时使用;创建后修改 .env 不会重置密码。" -ForegroundColor DarkGray
Write-Host " 有效期: 初始密码没有独立过期时间,在管理员修改密码前持续有效。" -ForegroundColor DarkGray
}
function Main {
Init-ProjectDir
@@ -425,19 +451,14 @@ function Main {
Write-Host "================================" -ForegroundColor Yellow
Write-Host ""
Write-Host " 预期访问: " -NoNewline; Write-Host "http://${ip}:3010" -ForegroundColor Cyan
Write-Host ""
Write-Host " 初始管理员: admin;随机密码保存在 .env 的 CONFIG_INITIAL_ADMIN_PASSWORD" -ForegroundColor DarkGray
} else {
Write-Host "================================" -ForegroundColor Green
Write-Host " 部署成功" -ForegroundColor Green
Write-Host "================================" -ForegroundColor Green
Write-Host ""
Write-Host " 访问地址: " -NoNewline; Write-Host "http://${ip}:3010" -ForegroundColor Cyan
Write-Host ""
Write-Host " -------- 初始管理员(首次登录后请修改密码)--------" -ForegroundColor Yellow
Write-Host " 账号: " -NoNewline; Write-Host "admin" -ForegroundColor White
Write-Host " 密码位置: " -NoNewline; Write-Host ".env -> CONFIG_INITIAL_ADMIN_PASSWORD" -ForegroundColor White
}
Show-AdminLoginInfo
Write-Host ""
Wait-ForExit
}