feat(microsoft): WIP: handle credentials expiration.

This commit is contained in:
huanghongxun
2021-10-12 14:04:18 +08:00
parent 28278c091d
commit 3433e88bb8
4 changed files with 53 additions and 8 deletions

View File

@@ -20,8 +20,9 @@ package org.jackhuang.hmcl.ui;
import org.jackhuang.hmcl.auth.Account;
import org.jackhuang.hmcl.auth.AuthInfo;
import org.jackhuang.hmcl.auth.AuthenticationException;
import org.jackhuang.hmcl.auth.microsoft.MicrosoftAccount;
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount;
import org.jackhuang.hmcl.ui.account.AccountLoginPane;
import org.jackhuang.hmcl.ui.account.AccountLoginWithPasswordDialog;
import java.util.Optional;
import java.util.concurrent.CancellationException;
@@ -39,7 +40,7 @@ public final class DialogController {
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<AuthInfo> res = new AtomicReference<>(null);
runInFX(() -> {
AccountLoginPane pane = new AccountLoginPane(account, it -> {
AccountLoginWithPasswordDialog pane = new AccountLoginWithPasswordDialog(account, it -> {
res.set(it);
latch.countDown();
}, latch::countDown);
@@ -47,6 +48,8 @@ public final class DialogController {
});
latch.await();
return Optional.ofNullable(res.get()).orElseThrow(CancellationException::new);
} else if (account instanceof MicrosoftAccount) {
}
return account.logIn();
}

View File

@@ -48,7 +48,7 @@ import static org.jackhuang.hmcl.ui.FXUtils.onEscPressed;
import static org.jackhuang.hmcl.util.Logging.LOG;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
public class AccountLoginPane extends StackPane {
public class AccountLoginWithPasswordDialog extends StackPane {
private final Account oldAccount;
private final Consumer<AuthInfo> success;
private final Runnable failed;
@@ -57,7 +57,7 @@ public class AccountLoginPane extends StackPane {
private final Label lblCreationWarning = new Label();
private final JFXProgressBar progressBar;
public AccountLoginPane(Account oldAccount, Consumer<AuthInfo> success, Runnable failed) {
public AccountLoginWithPasswordDialog(Account oldAccount, Consumer<AuthInfo> success, Runnable failed) {
this.oldAccount = oldAccount;
this.success = success;
this.failed = failed;