fix: validate admin email format in SaaS mode
Require user@domain.tld format (must contain @ and dot in domain). Interactive mode loops until valid; silent mode exits with error. Default changed from 'admin' to 'admin@<PUBLIC_HOST>' in SaaS mode. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
24
install.ps1
24
install.ps1
@@ -465,15 +465,15 @@ function Run-SimplePrompts {
|
||||
Write-Host ''
|
||||
if ($c.DeploymentMode -eq 'saas') {
|
||||
$defaultEmail = Coalesce $c.AdminUser "admin@$($c.PublicHost)"
|
||||
if ($defaultEmail -and -not $defaultEmail.Contains('@')) {
|
||||
if ($defaultEmail -and $defaultEmail -notmatch '@.+\..+') {
|
||||
$defaultEmail = "admin@$($c.PublicHost)"
|
||||
}
|
||||
$c.AdminUser = Prompt-Value 'Admin email' $defaultEmail
|
||||
# Validate email: must contain @
|
||||
if (-not $c.AdminUser.Contains('@')) {
|
||||
$original = $c.AdminUser
|
||||
$c.AdminUser = "$($c.AdminUser)@$($c.PublicHost)"
|
||||
Log-Info "Appended domain: '$original' -> '$($c.AdminUser)'"
|
||||
while ($true) {
|
||||
$c.AdminUser = Prompt-Value 'Admin email' $defaultEmail
|
||||
if ($c.AdminUser -match '^[^@]+@[^@]+\.[^@]+$') { break }
|
||||
Write-Host ' Invalid email address. Must be a valid email (e.g. admin@company.com).' -ForegroundColor Red
|
||||
$c.AdminUser = $null
|
||||
$defaultEmail = $null
|
||||
}
|
||||
} else {
|
||||
$c.AdminUser = Prompt-Value 'Admin username' (Coalesce $c.AdminUser $DEFAULT_ADMIN_USER)
|
||||
@@ -557,7 +557,15 @@ function Merge-Config {
|
||||
if (-not $c.InstallDir) { $c.InstallDir = $DEFAULT_INSTALL_DIR }
|
||||
if (-not $c.PublicHost) { $c.PublicHost = 'localhost' }
|
||||
if (-not $c.PublicProtocol) { $c.PublicProtocol = $DEFAULT_PUBLIC_PROTOCOL }
|
||||
if (-not $c.AdminUser) { $c.AdminUser = $DEFAULT_ADMIN_USER }
|
||||
if ($c.DeploymentMode -eq 'saas') {
|
||||
if (-not $c.AdminUser) { $c.AdminUser = "admin@$($c.PublicHost)" }
|
||||
if ($c.AdminUser -notmatch '^[^@]+@[^@]+\.[^@]+$') {
|
||||
Write-Host "ERROR: SAAS_ADMIN_USER must be a valid email address (e.g. admin@company.com), got: '$($c.AdminUser)'" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
} else {
|
||||
if (-not $c.AdminUser) { $c.AdminUser = $DEFAULT_ADMIN_USER }
|
||||
}
|
||||
if (-not $c.TlsMode) { $c.TlsMode = $DEFAULT_TLS_MODE }
|
||||
if (-not $c.HttpPort) { $c.HttpPort = $DEFAULT_HTTP_PORT }
|
||||
if (-not $c.HttpsPort) { $c.HttpsPort = $DEFAULT_HTTPS_PORT }
|
||||
|
||||
Reference in New Issue
Block a user