2626
2727import static me .goral .keepmypassworddesktop .util .AlertsUtil .showErrorDialog ;
2828import static me .goral .keepmypassworddesktop .util .ConfUtil .createConfFiles ;
29+ import static me .goral .keepmypassworddesktop .util .PasswordGeneratorUtil .checkPasswordComplexity ;
2930
3031public class MainAppController {
3132
@@ -79,11 +80,22 @@ protected void onLoginButtonClick() {
7980 username .setPromptText ("Username" );
8081 PasswordField password = new PasswordField ();
8182 password .setPromptText ("Password" );
83+ Label pwdCheck = new Label ("No password" );
84+ pwdCheck .setTextFill (Color .web ("#b3b3b3" ));
85+
86+ password .textProperty ().addListener ((observable , oldValue , newValue ) -> {
87+ Pair <String , Color > res = checkPasswordComplexity (newValue );
88+ pwdCheck .setText (res .getKey ());
89+ pwdCheck .setTextFill (res .getValue ());
90+ });
8291
8392 grid .add (new Label ("Username" ), 0 , 0 );
8493 grid .add (username , 1 , 0 );
8594 grid .add (new Label ("Password" ), 0 , 1 );
8695 grid .add (password , 1 , 1 );
96+ if (!login ) {
97+ grid .add (pwdCheck , 1 , 2 );
98+ }
8799
88100 username .textProperty ().addListener (((observableValue , oldV , newV ) -> regBtn .setDisable (newV .trim ().isEmpty ())));
89101
@@ -96,7 +108,7 @@ protected void onLoginButtonClick() {
96108 String newUname = username .getText ();
97109 String newPwd = password .getText ();
98110
99- Pair <String , Color > checker = PasswordGeneratorUtil . checkPasswordComplexity (newPwd );
111+ Pair <String , Color > checker = checkPasswordComplexity (newPwd );
100112
101113 if (password .getText ().isEmpty () && !login ){
102114 AlertsUtil .showErrorDialog ("Error" , "There is a problem." , "You can't register with empty password." );
@@ -219,11 +231,23 @@ protected void onLoginButtonClick(String unameString, String passwordString) {
219231 username .setText (unameString );
220232 PasswordField password = new PasswordField ();
221233 password .setText (passwordString );
234+ Label pwdCheck = new Label ("No password" );
235+ pwdCheck .setTextFill (Color .web ("#b3b3b3" ));
236+
237+ password .textProperty ().addListener ((observable , oldValue , newValue ) -> {
238+ Pair <String , Color > res = checkPasswordComplexity (newValue );
239+ pwdCheck .setText (res .getKey ());
240+ pwdCheck .setTextFill (res .getValue ());
241+ });
222242
223243 grid .add (new Label ("Username" ), 0 , 0 );
224244 grid .add (username , 1 , 0 );
225245 grid .add (new Label ("Password" ), 0 , 1 );
226246 grid .add (password , 1 , 1 );
247+ if (!login ) {
248+ grid .add (pwdCheck , 1 , 2 );
249+ }
250+
227251
228252 username .textProperty ().addListener (((observableValue , oldV , newV ) -> regBtn .setDisable (newV .trim ().isEmpty ())));
229253 regBtn .setDisable (unameString .trim ().isEmpty ());
@@ -237,7 +261,7 @@ protected void onLoginButtonClick(String unameString, String passwordString) {
237261 String newUname = username .getText ();
238262 String newPwd = password .getText ();
239263
240- Pair <String , Color > checker = PasswordGeneratorUtil . checkPasswordComplexity (newPwd );
264+ Pair <String , Color > checker = checkPasswordComplexity (newPwd );
241265
242266 if (password .getText ().isEmpty () && !login ){
243267 AlertsUtil .showErrorDialog ("Error" , "There is a problem." , "You can't register with empty password." );
0 commit comments