Fix onboarding state exception following restore (#19389)

Fixes #19388
This commit is contained in:
Cody C 2024-01-16 03:31:37 +13:00 committed by GitHub
parent f5994d2ae5
commit 62f6766e1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View File

@ -84,5 +84,9 @@ export const fetchInstallationType = async (): Promise<InstallationType> => {
throw Error("unauthorized");
}
if (response.status === 404) {
throw Error("not_found");
}
return response.json();
};

View File

@ -286,7 +286,7 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) {
try {
const response = await (window.stepsPromise || fetchOnboardingOverview());
if (response.status === 404) {
if (response.status === 401 || response.status === 404) {
// We don't load the component when onboarding is done
document.location.assign("/");
return;

View File

@ -62,7 +62,10 @@ class OnboardingRestoreBackup extends LitElement {
try {
await fetchInstallationType();
} catch (err: any) {
if ((err as Error).message === "unauthorized") {
if (
(err as Error).message === "unauthorized" ||
(err as Error).message === "not_found"
) {
window.location.replace("/");
}
}