# Test login with admin123
$loginBody1 = @{
    tenantCode = "T202605253515"
    username = "admin"
    password = "admin123"
} | ConvertTo-Json

Write-Output "=== Testing Login with admin123 ==="
try {
    $resp = Invoke-RestMethod -Uri "http://localhost:8006/login" -Method POST -ContentType "application/json" -Body $loginBody1
    Write-Output "Login code: $($resp.code)  msg: $($resp.msg)"
    if ($resp.token) {
        Write-Output "Token obtained!"
        $script:token = $resp.token
    }
} catch {
    Write-Output "Login error: $($_.Exception.Message)"
}

# Test with original password
$loginBody2 = @{
    tenantCode = "T202605253515"
    username = "admin"
    password = "FFuxUo5bC^ui"
} | ConvertTo-Json

Write-Output ""
Write-Output "=== Testing Login with FFuxUo5bC^ui ==="
try {
    $resp2 = Invoke-RestMethod -Uri "http://localhost:8006/login" -Method POST -ContentType "application/json" -Body $loginBody2
    Write-Output "Login code: $($resp2.code)  msg: $($resp2.msg)"
    if ($resp2.token) {
        Write-Output "Token obtained!"
    }
} catch {
    Write-Output "Login error: $($_.Exception.Message)"
}
