MCPcopy Create free account
hub / github.com/OWASP/SecurityShepherd / userDelete

Method userDelete

src/main/java/dbProcs/Setter.java:928–957  ·  view source on GitHub ↗
(String ApplicationRoot, String userId)

Source from the content-addressed store, hash-verified

926 }
927
928 public static boolean userDelete (String ApplicationRoot, String userId) throws SQLException
929 {
930 boolean result = false;
931 log.debug("*** Setter.userDelete ***");
932 log.debug("userId = " + userId);
933
934 Connection conn = Database.getCoreConnection(ApplicationRoot);
935 try {
936 log.debug("Deleting User's Results");
937 PreparedStatement callDelResults = conn.prepareStatement("DELETE FROM results WHERE userId = ?");
938 callDelResults.setString(1, userId);
939 callDelResults.executeUpdate();
940
941 log.debug("Executing delete from users on Database");
942 PreparedStatement callUserDel = conn.prepareStatement("DELETE FROM users WHERE userId = ?");
943 callUserDel.setString(1, userId);
944 int deleteAttemptResult = callUserDel.executeUpdate();
945
946 if (deleteAttemptResult == 1) {
947 result = true;
948 }
949 }
950 catch(SQLException sqlEx) {
951 log.fatal("userDelete Failure: " + sqlEx.toString());
952 throw new SQLException(sqlEx);
953 }
954 Database.closeConnection(conn);
955 log.debug("*** END userDelete ***");
956 return result;
957 }
958
959}

Callers 2

testUserDeleteMethod · 0.95
doPostMethod · 0.95

Calls 2

getCoreConnectionMethod · 0.95
closeConnectionMethod · 0.95

Tested by 1

testUserDeleteMethod · 0.76