$ErrorActionPreference = 'Stop'
Add-Type -AssemblyName System.Windows.Forms
. (Join-Path $PSScriptRoot 'Common.ps1')
try {
    $state = Get-RBConfiguration
    $language = Get-RBLanguage $state
    $portal = Invoke-RestMethod -Method Post -Uri "$($state.Config.gateway)/api/v1/portal-links?lang=$language" -Headers (Get-RBBasicHeader $state) -TimeoutSec 15
    if (-not $portal.portal_url) { throw (Get-RBText 'Il server non ha restituito il collegamento personale.' $language) }
    Start-Process $portal.portal_url
} catch {
    $language = if ($state) { Get-RBLanguage $state } else { Get-RBLanguage }
    [Windows.Forms.MessageBox]::Show("$(Get-RBText "Impossibile aprire l'area personale." $language)`n`n$($_.Exception.Message)", 'RansomBackup FREE', 'OK', 'Error') | Out-Null
}
