mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-21 12:11:28 +00:00
More refactoring following Sebastian comments
This commit is contained in:
@@ -97,9 +97,7 @@ public class ChangePasswordController extends LocalizedFXMLViewController {
|
||||
BooleanBinding newPasswordIsEmpty = newPasswordField.textProperty().isEmpty();
|
||||
BooleanBinding passwordsDiffer = newPasswordField.textProperty().isNotEqualTo(retypePasswordField.textProperty());
|
||||
changePasswordButton.disableProperty().bind(oldPasswordIsEmpty.or(newPasswordIsEmpty.or(passwordsDiffer)));
|
||||
EasyBind.subscribe(newPasswordField.textProperty(), this::checkPasswordStrength);
|
||||
|
||||
strengthRater.setLocalization(localization);
|
||||
passwordStrength.bind(EasyBind.map(newPasswordField.textProperty(), strengthRater::computeRate));
|
||||
|
||||
passwordStrengthShape.widthProperty().bind(EasyBind.map(passwordStrength, strengthRater::getWidth));
|
||||
passwordStrengthShape.fillProperty().bind(EasyBind.map(passwordStrength, strengthRater::getStrengthColor));
|
||||
@@ -153,13 +151,6 @@ public class ChangePasswordController extends LocalizedFXMLViewController {
|
||||
}
|
||||
}
|
||||
|
||||
// ****************************************
|
||||
// Password strength management
|
||||
// ****************************************
|
||||
|
||||
private void checkPasswordStrength(String password) {
|
||||
passwordStrength.set(strengthRater.computeRate(password));
|
||||
}
|
||||
/* Getter/Setter */
|
||||
|
||||
public ChangePasswordListener getListener() {
|
||||
|
||||
@@ -79,9 +79,7 @@ public class InitializeController extends LocalizedFXMLViewController {
|
||||
BooleanBinding passwordIsEmpty = passwordField.textProperty().isEmpty();
|
||||
BooleanBinding passwordsDiffer = passwordField.textProperty().isNotEqualTo(retypePasswordField.textProperty());
|
||||
okButton.disableProperty().bind(passwordIsEmpty.or(passwordsDiffer));
|
||||
EasyBind.subscribe(passwordField.textProperty(), this::checkPasswordStrength);
|
||||
|
||||
strengthRater.setLocalization(localization);
|
||||
passwordStrength.bind(EasyBind.map(passwordField.textProperty(), strengthRater::computeRate));
|
||||
|
||||
passwordStrengthShape.widthProperty().bind(EasyBind.map(passwordStrength, strengthRater::getWidth));
|
||||
passwordStrengthShape.fillProperty().bind(EasyBind.map(passwordStrength, strengthRater::getStrengthColor));
|
||||
@@ -125,12 +123,6 @@ public class InitializeController extends LocalizedFXMLViewController {
|
||||
this.listener = Optional.ofNullable(listener);
|
||||
}
|
||||
|
||||
/* Methods */
|
||||
|
||||
private void checkPasswordStrength(String password) {
|
||||
passwordStrength.set(strengthRater.computeRate(password));
|
||||
}
|
||||
|
||||
/* callback */
|
||||
|
||||
private void invokeListenerLater(InitializationListener listener) {
|
||||
|
||||
@@ -22,14 +22,16 @@ import java.util.List;
|
||||
@Singleton
|
||||
public class PasswordStrengthUtil {
|
||||
|
||||
private Zxcvbn zxcvbn = new Zxcvbn();
|
||||
private List<String> sanitizedInputs = new ArrayList<>();
|
||||
private Localization localization;
|
||||
private final Zxcvbn zxcvbn;
|
||||
private final List<String> sanitizedInputs;
|
||||
private final Localization localization;
|
||||
|
||||
@Inject
|
||||
public PasswordStrengthUtil(){
|
||||
// preparing inputs for the password strength checker
|
||||
sanitizedInputs.add("cryptomator");
|
||||
public PasswordStrengthUtil(Localization localization){
|
||||
this.localization = localization;
|
||||
this.zxcvbn = new Zxcvbn();
|
||||
this.sanitizedInputs = new ArrayList<>();
|
||||
this.sanitizedInputs.add("cryptomator");
|
||||
}
|
||||
|
||||
public int computeRate(String password) {
|
||||
@@ -107,14 +109,4 @@ public class PasswordStrengthUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/* Getter / Setter */
|
||||
|
||||
public Localization getLocalization() {
|
||||
return localization;
|
||||
}
|
||||
|
||||
public void setLocalization(Localization localization) {
|
||||
this.localization = localization;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user