Android: get login working
This commit is contained in:
parent
b165ec6005
commit
917fe6a0f9
2 changed files with 14 additions and 8 deletions
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
<!-- Include one or more domains that should be verified. -->
|
<!-- Include one or more domains that should be verified. -->
|
||||||
<data android:host="app.mapcomplete.org" />
|
<data android:host="app.mapcomplete.org" />
|
||||||
<data android:path="/land.html" />
|
<data android:path="/passthrough.html" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ public class MainActivity extends BridgeActivity {
|
||||||
private PluginCall locationRequest = null;
|
private PluginCall locationRequest = null;
|
||||||
private PluginCall authRequest = null;
|
private PluginCall authRequest = null;
|
||||||
|
|
||||||
|
private JSObject loginToken = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
registerPlugin(Databridge.class);
|
registerPlugin(Databridge.class);
|
||||||
|
@ -31,6 +33,9 @@ public class MainActivity extends BridgeActivity {
|
||||||
});
|
});
|
||||||
Databridge.addResponder("request:login", pluginCall -> {
|
Databridge.addResponder("request:login", pluginCall -> {
|
||||||
this.authRequest = pluginCall;
|
this.authRequest = pluginCall;
|
||||||
|
if(this.loginToken != null){
|
||||||
|
pluginCall.resolve(this.loginToken);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
@ -62,16 +67,17 @@ public class MainActivity extends BridgeActivity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Objects.equals(url.getPath(), "/land.html")) {
|
if (Objects.equals(url.getPath(), "/passthrough.html")) {
|
||||||
var code = url.getQueryParameter("code");
|
var token = url.getQueryParameter("oauth_token");
|
||||||
var state = url.getQueryParameter("state");
|
|
||||||
JSObject obj = new JSObject();
|
JSObject obj = new JSObject();
|
||||||
obj.put("code", code);
|
obj.put("oauth_token", token);
|
||||||
obj.put("state", state);
|
|
||||||
JSObject res = new JSObject();
|
JSObject res = new JSObject();
|
||||||
res.put("value", obj);
|
res.put("value", obj);
|
||||||
Log.i("main", "Resolving auth call");
|
Log.i("main", "Resolving auth call, param is " + token);
|
||||||
this.authRequest.resolve(res);
|
this.loginToken = res;
|
||||||
|
if(this.authRequest != null){
|
||||||
|
this.authRequest.resolve(res);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue