mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 16:26:43 +00:00
Fix keep me logged in (#10835)
This commit is contained in:
parent
7039bae9be
commit
faccb12430
@ -37,21 +37,7 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const authProm = isExternal
|
const clearUrlParams = () => {
|
||||||
? () =>
|
|
||||||
import("../external_app/external_auth").then(({ createExternalAuth }) =>
|
|
||||||
createExternalAuth(hassUrl)
|
|
||||||
)
|
|
||||||
: () =>
|
|
||||||
getAuth({
|
|
||||||
hassUrl,
|
|
||||||
saveTokens,
|
|
||||||
loadTokens: () => Promise.resolve(loadTokens()),
|
|
||||||
});
|
|
||||||
|
|
||||||
const connProm = async (auth) => {
|
|
||||||
try {
|
|
||||||
const conn = await createConnection({ auth });
|
|
||||||
// Clear auth data from url if we have been able to establish a connection
|
// Clear auth data from url if we have been able to establish a connection
|
||||||
if (location.search.includes("auth_callback=1")) {
|
if (location.search.includes("auth_callback=1")) {
|
||||||
const searchParams = new URLSearchParams(location.search);
|
const searchParams = new URLSearchParams(location.search);
|
||||||
@ -68,7 +54,24 @@ const connProm = async (auth) => {
|
|||||||
`${location.pathname}${search ? `?${search}` : ""}`
|
`${location.pathname}${search ? `?${search}` : ""}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const authProm = isExternal
|
||||||
|
? () =>
|
||||||
|
import("../external_app/external_auth").then(({ createExternalAuth }) =>
|
||||||
|
createExternalAuth(hassUrl)
|
||||||
|
)
|
||||||
|
: () =>
|
||||||
|
getAuth({
|
||||||
|
hassUrl,
|
||||||
|
saveTokens,
|
||||||
|
loadTokens: () => Promise.resolve(loadTokens()),
|
||||||
|
});
|
||||||
|
|
||||||
|
const connProm = async (auth) => {
|
||||||
|
try {
|
||||||
|
const conn = await createConnection({ auth });
|
||||||
|
clearUrlParams();
|
||||||
return { auth, conn };
|
return { auth, conn };
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
if (err !== ERR_INVALID_AUTH) {
|
if (err !== ERR_INVALID_AUTH) {
|
||||||
@ -85,6 +88,7 @@ const connProm = async (auth) => {
|
|||||||
}
|
}
|
||||||
auth = await authProm();
|
auth = await authProm();
|
||||||
const conn = await createConnection({ auth });
|
const conn = await createConnection({ auth });
|
||||||
|
clearUrlParams();
|
||||||
return { auth, conn };
|
return { auth, conn };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -127,7 +127,9 @@ export class HassRouterPage extends ReactiveElement {
|
|||||||
|
|
||||||
// Update the url if we know where we're mounted.
|
// Update the url if we know where we're mounted.
|
||||||
if (route) {
|
if (route) {
|
||||||
navigate(`${route.prefix}/${result}`, { replace: true });
|
navigate(`${route.prefix}/${result}${location.search}`, {
|
||||||
|
replace: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,9 @@ export class HomeAssistantAppEl extends QuickBarMixin(HassElement) {
|
|||||||
const path = curPath();
|
const path = curPath();
|
||||||
|
|
||||||
if (["", "/"].includes(path)) {
|
if (["", "/"].includes(path)) {
|
||||||
navigate(`/${getStorageDefaultPanelUrlPath()}`, { replace: true });
|
navigate(`/${getStorageDefaultPanelUrlPath()}${location.search}`, {
|
||||||
|
replace: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
this._route = {
|
this._route = {
|
||||||
prefix: "",
|
prefix: "",
|
||||||
|
@ -698,7 +698,7 @@ class HUIRoot extends LitElement {
|
|||||||
|
|
||||||
private _navigateToView(path: string | number, replace?: boolean) {
|
private _navigateToView(path: string | number, replace?: boolean) {
|
||||||
if (!this.lovelace!.editMode) {
|
if (!this.lovelace!.editMode) {
|
||||||
navigate(`${this.route!.prefix}/${path}`, { replace });
|
navigate(`${this.route!.prefix}/${path}${location.search}`, { replace });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
navigate(`${this.route!.prefix}/${path}?${addSearchParam({ edit: "1" })}`, {
|
navigate(`${this.route!.prefix}/${path}?${addSearchParam({ edit: "1" })}`, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user