Skip to content

Commit

Permalink
Some minor debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Saefurukawa committed May 1, 2024
1 parent 3aef8db commit 4e33130
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ public void handleSubmit() {
response.setText(jsonObj.getString("reason"));
} else if (jsonObj.getString("result").equals("SUCCESS")){
response.setText("Account created");
passwordTextfield.setText("");
legalFirstNameTextfield.setText("");
legalLastNameTextfield.setText("");
addressTextfield.setText("");
dobDatePicker.setValue(null);

}
}

Expand Down
55 changes: 36 additions & 19 deletions HealthHaven/src/org/healthhaven/db/models/AccountDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,44 @@ public static synchronized JSONObject updateTemporaryUserAfterFirstLogin(Connect
reason = "Error verifying the DOB";

} else {
// Step 3: Update users table
// Step 5: Update authentication table (with password update)
String usersUpdateSql = "UPDATE healthhaven.users SET legalfirstname = ?, legallastname = ?, address = ?, data_sharing = TRUE WHERE userid = ?";
String authenticationUpdateSql = "UPDATE healthhaven.authentication SET password = ?, totp_key = ?, reset = ?, salt = ?, hashpass=? WHERE userid = ?";
if (!updateUserTable(conn, usersUpdateSql, legalfirstname, legallastname, address, userId)
|| !updateAuthenticationTable(conn, authenticationUpdateSql, password, true, TOTP.genSecretKey(),
userId)) {
result = "FAILURE";
reason = "Database Entry Error";
} else {
try {
conn.commit();
} catch (SQLException e) {
try {
conn.rollback();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();

String sql = "SELECT * FROM healthhaven.authentication WHERE email = '" + email + "'";

try (PreparedStatement stmt = conn.prepareStatement(sql)) {
ResultSet data_rs = stmt.executeQuery();
boolean resetValue = data_rs.getBoolean("reset");
if (resetValue) {
result = "FAILURE";
reason = "Account already exist";
} else {
// Step 3: Update users table
// Step 5: Update authentication table (with password update)
String usersUpdateSql = "UPDATE healthhaven.users SET legalfirstname = ?, legallastname = ?, address = ?, data_sharing = TRUE WHERE userid = ?";
String authenticationUpdateSql = "UPDATE healthhaven.authentication SET password = ?, totp_key = ?, reset = ?, salt = ?, hashpass=? WHERE userid = ?";
if (!updateUserTable(conn, usersUpdateSql, legalfirstname, legallastname, address, userId)
|| !updateAuthenticationTable(conn, authenticationUpdateSql, password, true, TOTP.genSecretKey(),
userId)) {
result = "FAILURE";
reason = "Database Entry Error";
} else {
try {
conn.commit();
} catch (SQLException e) {
try {
conn.rollback();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
e.printStackTrace();
}
}
e.printStackTrace();

}

} catch (SQLException e) {
result = "FAILURE";
reason = "Error Authenticating User";
}

}
Expand Down

0 comments on commit 4e33130

Please sign in to comment.