diff --git a/app/land.ts b/app/land.ts index 73a7a9998..a8ac65d7c 100644 --- a/app/land.ts +++ b/app/land.ts @@ -2,8 +2,6 @@ import { OsmConnection } from "../src/Logic/Osm/OsmConnection" import Constants from "../src/Models/Constants" import { Utils } from "../src/Utils" import { UIEventSource } from "../src/Logic/UIEventSource" -import { VariableUiElement } from "../src/UI/Base/VariableUIElement" -import Combine from "../src/UI/Base/Combine" import { QueryParameters } from "../src/Logic/Web/QueryParameters" console.log("Authorizing...") @@ -13,12 +11,6 @@ console.log("Prev state is", key, st) const tokenSrc = new UIEventSource("") const debug = new UIEventSource([]) -new Combine([ - new VariableUiElement( - debug.map((debug) => "") - ), - new VariableUiElement(tokenSrc), -]).AttachTo("token") const connection = new OsmConnection() connection.finishLogin(async () => { diff --git a/src/land.ts b/src/land.ts index 57ca606bf..cf73b2bd1 100644 --- a/src/land.ts +++ b/src/land.ts @@ -1,16 +1,22 @@ +import { QueryParameters } from "./Logic/Web/QueryParameters" import { OsmConnection } from "./Logic/Osm/OsmConnection" -import Constants from "./Models/Constants" +import { LocalStorageSource } from "./Logic/Web/LocalStorageSource" console.log("Authorizing...") -const key = Constants.osmAuthConfig.url + "oauth2_state" -const st = window.localStorage.getItem(key) -console.log("Prev state is", key, st) -new OsmConnection().finishLogin((previousURL) => { - const fallback = window.location.protocol + "//" + window.location.host + "/index.html" - previousURL ??= fallback - if (previousURL.indexOf("/land") > 0) { - previousURL = fallback - } - console.log("Redirecting to", previousURL) - window.location.href = previousURL -}) + +if (QueryParameters.wasInitialized("error")) { +// error=access_denied&error_description=The+resource+owner+or+authorization+server+denied+the+request. + alert("Access was denied") + const previousLocation = LocalStorageSource.get("location_before_login") + window.location.href = previousLocation.data ?? "./" +} else { + new OsmConnection().finishLogin((previousURL) => { + const fallback = window.location.protocol + "//" + window.location.host + "/index.html" + previousURL ??= fallback + if (previousURL.indexOf("/land") > 0) { + previousURL = fallback + } + console.log("Redirecting to", previousURL) + window.location.href = previousURL + }) +}