fix(license): degrade to free when servers unreachable or key rejected

On startup, if the license server was unreachable with no usable cached status, or the server rejected the key, we only logged a warning without clearing persisted license.state. On Redis/keyvalue deployments a previous run's Licensed=true could remain active even though pro features were advertised as unavailable. Route both paths through degradeToFree so the persisted state is cleared.
This commit is contained in:
kolaente 2026-04-20 19:40:36 +02:00 committed by kolaente
parent c8893f4533
commit 73a0f691ec
1 changed files with 5 additions and 2 deletions

View File

@ -180,10 +180,13 @@ func Init() {
log.Fatalf("Could not apply cached license: %s", err)
}
} else {
log.Warningf("Could not reach any license server and no cached validation exists. Pro features will not be available. Please check your network connectivity.")
// Clear any persisted Licensed=true state from a previous run
// (e.g. via Redis keyvalue) so a now-unreachable server can't
// leave stale entitlements active.
degradeToFree("Could not reach any license server and no cached validation exists. Pro features will not be available.")
}
case !resp.Valid:
log.Warningf("License key is invalid: %s. Pro features will not be available.", resp.Message)
degradeToFree(fmt.Sprintf("License key is invalid: %s.", resp.Message))
default:
applyResponse(resp)
if err := cacheResponse(resp); err != nil {