mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Keep user signed in during onboarding (#17669)
This commit is contained in:
parent
7e7205627a
commit
3249a5225f
@ -27,6 +27,11 @@ import { registerServiceWorker } from "../util/register-service-worker";
|
|||||||
import "./onboarding-analytics";
|
import "./onboarding-analytics";
|
||||||
import "./onboarding-create-user";
|
import "./onboarding-create-user";
|
||||||
import "./onboarding-loading";
|
import "./onboarding-loading";
|
||||||
|
import {
|
||||||
|
enableWrite,
|
||||||
|
loadTokens,
|
||||||
|
saveTokens,
|
||||||
|
} from "../common/auth/token_storage";
|
||||||
|
|
||||||
type OnboardingEvent =
|
type OnboardingEvent =
|
||||||
| {
|
| {
|
||||||
@ -212,6 +217,8 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) {
|
|||||||
const auth = await getAuth({
|
const auth = await getAuth({
|
||||||
hassUrl,
|
hassUrl,
|
||||||
limitHassInstance: true,
|
limitHassInstance: true,
|
||||||
|
saveTokens,
|
||||||
|
loadTokens: () => Promise.resolve(loadTokens()),
|
||||||
});
|
});
|
||||||
history.replaceState(null, "", location.pathname);
|
history.replaceState(null, "", location.pathname);
|
||||||
await this._connectHass(auth);
|
await this._connectHass(auth);
|
||||||
@ -235,11 +242,13 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) {
|
|||||||
if (stepResult.type === "user") {
|
if (stepResult.type === "user") {
|
||||||
const result = stepResult.result as OnboardingResponses["user"];
|
const result = stepResult.result as OnboardingResponses["user"];
|
||||||
this._loading = true;
|
this._loading = true;
|
||||||
|
enableWrite();
|
||||||
try {
|
try {
|
||||||
const auth = await getAuth({
|
const auth = await getAuth({
|
||||||
hassUrl,
|
hassUrl,
|
||||||
limitHassInstance: true,
|
limitHassInstance: true,
|
||||||
authCode: result.auth_code,
|
authCode: result.auth_code,
|
||||||
|
saveTokens,
|
||||||
});
|
});
|
||||||
await this._connectHass(auth);
|
await this._connectHass(auth);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user