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
				
			
		| 
						 | 
					@ -2,8 +2,6 @@ import { OsmConnection } from "../src/Logic/Osm/OsmConnection"
 | 
				
			||||||
import Constants from "../src/Models/Constants"
 | 
					import Constants from "../src/Models/Constants"
 | 
				
			||||||
import { Utils } from "../src/Utils"
 | 
					import { Utils } from "../src/Utils"
 | 
				
			||||||
import { UIEventSource } from "../src/Logic/UIEventSource"
 | 
					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"
 | 
					import { QueryParameters } from "../src/Logic/Web/QueryParameters"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
console.log("Authorizing...")
 | 
					console.log("Authorizing...")
 | 
				
			||||||
| 
						 | 
					@ -13,12 +11,6 @@ console.log("Prev state is", key, st)
 | 
				
			||||||
const tokenSrc = new UIEventSource("")
 | 
					const tokenSrc = new UIEventSource("")
 | 
				
			||||||
const debug = new UIEventSource<string[]>([])
 | 
					const debug = new UIEventSource<string[]>([])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
new Combine([
 | 
					 | 
				
			||||||
    new VariableUiElement(
 | 
					 | 
				
			||||||
        debug.map((debug) => "<ul><li>" + debug.join("</li><li>") + "</li></ul>")
 | 
					 | 
				
			||||||
    ),
 | 
					 | 
				
			||||||
    new VariableUiElement(tokenSrc),
 | 
					 | 
				
			||||||
]).AttachTo("token")
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const connection = new OsmConnection()
 | 
					const connection = new OsmConnection()
 | 
				
			||||||
connection.finishLogin(async () => {
 | 
					connection.finishLogin(async () => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										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 { OsmConnection } from "./Logic/Osm/OsmConnection"
 | 
				
			||||||
import Constants from "./Models/Constants"
 | 
					import { LocalStorageSource } from "./Logic/Web/LocalStorageSource"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
console.log("Authorizing...")
 | 
					console.log("Authorizing...")
 | 
				
			||||||
const key = Constants.osmAuthConfig.url + "oauth2_state"
 | 
					
 | 
				
			||||||
const st = window.localStorage.getItem(key)
 | 
					if (QueryParameters.wasInitialized("error")) {
 | 
				
			||||||
console.log("Prev state is", key, st)
 | 
					// error=access_denied&error_description=The+resource+owner+or+authorization+server+denied+the+request.
 | 
				
			||||||
new OsmConnection().finishLogin((previousURL) => {
 | 
					    alert("Access was denied")
 | 
				
			||||||
    const fallback = window.location.protocol + "//" + window.location.host + "/index.html"
 | 
					    const previousLocation = LocalStorageSource.get("location_before_login")
 | 
				
			||||||
    previousURL ??= fallback
 | 
					    window.location.href = previousLocation.data ?? "./"
 | 
				
			||||||
    if (previousURL.indexOf("/land") > 0) {
 | 
					} else {
 | 
				
			||||||
        previousURL = fallback
 | 
					    new OsmConnection().finishLogin((previousURL) => {
 | 
				
			||||||
    }
 | 
					        const fallback = window.location.protocol + "//" + window.location.host + "/index.html"
 | 
				
			||||||
    console.log("Redirecting to", previousURL)
 | 
					        previousURL ??= fallback
 | 
				
			||||||
    window.location.href = previousURL
 | 
					        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