mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-15 06:45:42 -04:00
Merge branch 'javafx' of https://github.com/huanghongxun/HMCL into javafx
This commit is contained in:
commit
8108f11c45
@ -114,7 +114,7 @@ public class AddAccountPane extends StackPane {
|
|||||||
cboServers.visibleProperty().bind(loginType.isEqualTo(Accounts.FACTORY_AUTHLIB_INJECTOR));
|
cboServers.visibleProperty().bind(loginType.isEqualTo(Accounts.FACTORY_AUTHLIB_INJECTOR));
|
||||||
lblInjectorServer.visibleProperty().bind(cboServers.visibleProperty());
|
lblInjectorServer.visibleProperty().bind(cboServers.visibleProperty());
|
||||||
|
|
||||||
txtUsername.getValidators().add(new Validator(i18n("input.email"), str -> !txtPassword.isVisible() || str.contains("@")));
|
txtUsername.getValidators().add(new Validator(i18n("input.email"), this::validateUsername));
|
||||||
|
|
||||||
btnAccept.disableProperty().bind(Bindings.createBooleanBinding(
|
btnAccept.disableProperty().bind(Bindings.createBooleanBinding(
|
||||||
() -> !( // consider the opposite situation: input is valid
|
() -> !( // consider the opposite situation: input is valid
|
||||||
@ -123,9 +123,9 @@ public class AddAccountPane extends StackPane {
|
|||||||
(!txtPassword.isVisible() || txtPassword.validate()) &&
|
(!txtPassword.isVisible() || txtPassword.validate()) &&
|
||||||
(!cboServers.isVisible() || cboServers.getSelectionModel().getSelectedItem() != null)
|
(!cboServers.isVisible() || cboServers.getSelectionModel().getSelectedItem() != null)
|
||||||
),
|
),
|
||||||
txtUsername.textProperty(),
|
txtUsername.textProperty(), txtPassword.textProperty(),
|
||||||
txtPassword.textProperty(), txtPassword.visibleProperty(),
|
loginType, cboServers.getSelectionModel().selectedItemProperty(),
|
||||||
cboServers.getSelectionModel().selectedItemProperty(), cboServers.visibleProperty()));
|
txtPassword.visibleProperty(), cboServers.visibleProperty()));
|
||||||
|
|
||||||
// authlib-injector links
|
// authlib-injector links
|
||||||
links.bind(BindingMapping.of(cboServers.getSelectionModel().selectedItemProperty())
|
links.bind(BindingMapping.of(cboServers.getSelectionModel().selectedItemProperty())
|
||||||
@ -135,6 +135,20 @@ public class AddAccountPane extends StackPane {
|
|||||||
linksContainer.visibleProperty().bind(cboServers.visibleProperty());
|
linksContainer.visibleProperty().bind(cboServers.visibleProperty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean validateUsername(String username) {
|
||||||
|
AccountFactory<?> loginType = cboType.getSelectionModel().getSelectedItem();
|
||||||
|
if (loginType == Accounts.FACTORY_OFFLINE) {
|
||||||
|
return true;
|
||||||
|
} else if (loginType == Accounts.FACTORY_AUTHLIB_INJECTOR) {
|
||||||
|
AuthlibInjectorServer server = cboServers.getSelectionModel().getSelectedItem();
|
||||||
|
if (server != null && server.isNonEmailLogin()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return username.contains("@");
|
||||||
|
}
|
||||||
|
|
||||||
private static final String[] ALLOWED_LINKS = { "register" };
|
private static final String[] ALLOWED_LINKS = { "register" };
|
||||||
|
|
||||||
public static List<Hyperlink> createHyperlinks(AuthlibInjectorServer server) {
|
public static List<Hyperlink> createHyperlinks(AuthlibInjectorServer server) {
|
||||||
|
@ -110,6 +110,7 @@ public class AuthlibInjectorServer implements Observable {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private transient String name;
|
private transient String name;
|
||||||
private transient Map<String, String> links = emptyMap();
|
private transient Map<String, String> links = emptyMap();
|
||||||
|
private transient boolean nonEmailLogin;
|
||||||
|
|
||||||
private transient boolean metadataRefreshed;
|
private transient boolean metadataRefreshed;
|
||||||
private final transient ObservableHelper helper = new ObservableHelper(this);
|
private final transient ObservableHelper helper = new ObservableHelper(this);
|
||||||
@ -145,6 +146,10 @@ public class AuthlibInjectorServer implements Observable {
|
|||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNonEmailLogin() {
|
||||||
|
return nonEmailLogin;
|
||||||
|
}
|
||||||
|
|
||||||
public String fetchMetadataResponse() throws IOException {
|
public String fetchMetadataResponse() throws IOException {
|
||||||
if (metadataResponse == null || !metadataRefreshed) {
|
if (metadataResponse == null || !metadataRefreshed) {
|
||||||
refreshMetadata();
|
refreshMetadata();
|
||||||
@ -194,6 +199,9 @@ public class AuthlibInjectorServer implements Observable {
|
|||||||
return converted;
|
return converted;
|
||||||
})
|
})
|
||||||
.orElse(emptyMap());
|
.orElse(emptyMap());
|
||||||
|
this.nonEmailLogin = metaObject.flatMap(meta -> tryCast(meta.get("feature.non_email_login"), JsonPrimitive.class))
|
||||||
|
.map(it -> it.getAsBoolean())
|
||||||
|
.orElse(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user