forked from MapComplete/MapComplete
UX: minimal fix for https://github.com/pietervdvn/MapComplete/issues/2284
This commit is contained in:
parent
8d643fcf69
commit
2d673089ab
2 changed files with 19 additions and 21 deletions
32
src/land.ts
32
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
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue