Android: get login working

This commit is contained in:
Pieter Vander Vennet 2024-12-31 19:55:08 +01:00
parent 00c233a2eb
commit 88c76498b6
16 changed files with 199 additions and 171 deletions

View file

@ -3,6 +3,7 @@
<head><title>MapComplete Auth</title></head>
<body>
Authorizing and redirecting, hang on...
<div id="token"></div>
<script type="module" src="./land.ts"></script>
</body>
</html>

View file

@ -1,11 +1,17 @@
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"
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((_, token: string) => {
console.log("Login finished, redirecting to passthrough")
const tokenSrc = new UIEventSource("")
new VariableUiElement(tokenSrc).AttachTo("token")
new OsmConnection().finishLogin(async (_, token: string) => {
console.log("Login finished, redirecting to passthrough; token is "+token)
await Utils.waitFor(10)
window.location.href = "https://app.mapcomplete.org/passthrough.html?oauth_token="+token
})