java - Pass input from FXML text field to BCrypt.checkpassword -
i having first crack @ both fxml , bcrypt learning exercise.
i have 2 text fields in fxml , plan concatinate them in string compare hash bcrypt.
this example.fxml
<textfield fx:id="userid" layoutx="103.0" layouty="56.0" onaction="#loginpressed"/> <passwordfield fx:id="passwordfield" layoutx="103.0" layouty="111.0" onaction="#loginpressed"/>
this loginpage.java
private void loginpressed(actionevent event) { if (bcrypt.checkpw((unpwfield), passwordhash)) system.out.println("accepted"); else system.out.println("denied"); }
i thought answer be
private string unpwfield = userid+passwordfield;
but doesnt work. (the operator + undefined argument type(s) javafx.scene.control.textfield, javafx.scene.control.textfield) why?
edit
i have tried following gives nullpointer
string unpwfield; unpwfield = userid.gettext()+passwordfield.gettext(); if (bcrypt.checkpw(unpwfield, passwordhash)) system.out.println("it matches"); else system.out.println(userid.gettext()+passwordfield.gettext());
turn out code correct. hadnt injected @fxml passwordfield
Comments
Post a Comment