Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,8 @@ public CompletableFuture<Void> show(AuthWebViewDetails details) {
public CompletableFuture<LoginScene.LoginAndPasswordResult> auth(AuthWebViewDetails details) {
overlay.future = new CompletableFuture<>();
overlay.follow(details.url, details.redirectUrl, (r) -> {
String code = r;
LogHelper.debug("Code: %s", code);
if (code.startsWith("?code=")) {
code = r.substring("?code=".length(), r.indexOf("&"));
}
LogHelper.debug("Code: %s", code);
overlay.future.complete(new LoginScene.LoginAndPasswordResult(null, new AuthCodePassword(code)));
LogHelper.dev("Redirect uri: %s", r);
overlay.future.complete(new LoginScene.LoginAndPasswordResult(null, new AuthCodePassword(r)));
});
return overlay.future;
}
Expand Down Expand Up @@ -118,16 +113,16 @@ protected void doInit() {
}

public void follow(String url, String redirectUrl, Consumer<String> redirectCallback) {
LogHelper.debug("Load url %s", url);
LogHelper.dev("Load url %s", url);
webView.getEngine().setJavaScriptEnabled(true);
webView.getEngine().load(url);
if (redirectCallback != null) {
webView.getEngine().locationProperty().addListener((obs, oldLocation, newLocation) -> {
if (newLocation != null) {
LogHelper.debug("Location: %s", newLocation);
LogHelper.dev("Location: %s", newLocation);
if (redirectUrl != null) {
if (newLocation.startsWith(redirectUrl)) {
redirectCallback.accept(newLocation.substring(redirectUrl.length()));
redirectCallback.accept(newLocation);
}
} else {
redirectCallback.accept(newLocation);
Expand Down