Files
ColaFlow/relogin-test-user.ps1
Yaojia Wang b11c6447b5
Some checks failed
Code Coverage / Generate Coverage Report (push) Has been cancelled
Tests / Run Tests (9.0.x) (push) Has been cancelled
Tests / Docker Build Test (push) Has been cancelled
Tests / Test Summary (push) Has been cancelled
Sync
2025-11-08 18:13:48 +01:00

43 lines
1.9 KiB
PowerShell

# ColaFlow 重新登录脚本
# 获取新的 JWT Token
$apiUrl = "http://localhost:5167"
Write-Host "🔑 正在登录测试账号..." -ForegroundColor Cyan
# 登录请求
$loginPayload = @{
tenantSlug = "testcompany"
email = "admin@test.com"
password = "Admin@123456"
} | ConvertTo-Json
try {
$response = Invoke-RestMethod -Uri "$apiUrl/api/auth/login" -Method Post -Body $loginPayload -ContentType "application/json"
Write-Host "✅ 登录成功!" -ForegroundColor Green
Write-Host ""
Write-Host "📋 用户信息:" -ForegroundColor Yellow
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Yellow
Write-Host "用户 ID: $($response.user.id)" -ForegroundColor White
Write-Host "邮箱: $($response.user.email)" -ForegroundColor White
Write-Host "姓名: $($response.user.fullName)" -ForegroundColor White
Write-Host "租户 ID: $($response.user.tenantId)" -ForegroundColor White
Write-Host "租户名称: $($response.user.tenantName)" -ForegroundColor White
Write-Host "角色: $($response.user.role)" -ForegroundColor White
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Yellow
Write-Host ""
Write-Host "🔑 JWT Token (前50字符):" -ForegroundColor Cyan
Write-Host $response.accessToken.Substring(0, [Math]::Min(50, $response.accessToken.Length))... -ForegroundColor Gray
Write-Host ""
Write-Host "💡 提示: 请在前端浏览器重新登录以获取有效的 Token" -ForegroundColor Yellow
} catch {
$statusCode = $_.Exception.Response.StatusCode.value__
$errorBody = $_.ErrorDetails.Message
Write-Host "❌ 登录失败" -ForegroundColor Red
Write-Host "状态码: $statusCode" -ForegroundColor Red
Write-Host "错误详情: $errorBody" -ForegroundColor Red
}