MapComplete/src/land.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
929 B
TypeScript
Raw Normal View History

import { QueryParameters } from "./Logic/Web/QueryParameters"
2023-09-21 15:29:34 +02:00
import { OsmConnection } from "./Logic/Osm/OsmConnection"
import { LocalStorageSource } from "./Logic/Web/LocalStorageSource"
2023-09-01 21:36:39 +02:00
2023-09-21 15:29:34 +02:00
console.log("Authorizing...")
if (QueryParameters.wasInitialized("error")) {
2025-03-06 16:21:55 +01:00
// 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
})
}