Skip to content
Snippets Groups Projects
Commit 56c98c45 authored by Yannis Devos's avatar Yannis Devos
Browse files

Ajout delete user dans le dao et servlet account, sans pouvoir tester

parent 3d2af569
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="ASK" />
<option name="description" value="" />
<option name="applicationTheme" value="default" />
<option name="iconsTheme" value="default" />
<option name="button1Title" value="" />
<option name="button1Url" value="" />
<option name="button2Title" value="" />
<option name="button2Url" value="" />
<option name="customApplicationId" value="" />
</component>
</project>
\ No newline at end of file
<component name="libraryTable">
<library name="lib1">
<CLASSES>
<root url="file://$PROJECT_DIR$/../../lib" />
</CLASSES>
<JAVADOC />
<SOURCES />
<jarDirectory url="file://$PROJECT_DIR$/../../lib" recursive="false" />
</library>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="userId" value="783852a9:19599df681a:-7fe2" />
</MTProjectMetadataState>
</option>
</component>
</project>
\ No newline at end of file
......@@ -32,7 +32,11 @@ public class DeleteAccount extends HttpServlet {
out.println("<link rel=\"stylesheet\" href=\"css/account.css\">");
out.println("<title>Account</title>");
out.println("</body>");
out.println("Your account was successfully deleted !");
if (userDao.deleteUser(user.getUserName(), user.getPwd())){
out.println("Your account was successfully deleted !");
}else {
out.println("A problem occurred while deleting your account...");
}
}
} else {
res.sendRedirect("/s4a021-web-backend/");
......
......@@ -48,6 +48,22 @@ public class UserDAO {
return false;
}
public boolean deleteUser(String username, String password){
try{
if (isDatabased(getUserByLogs(username, password))) {
PreparedStatement stmt = this.con.prepareStatement("DELETE FROM userAccount WHERE username=? AND password=?");
stmt.setString(1, username);
stmt.setString(2, password);
stmt.executeUpdate();
return true;
}
}catch (SQLException sqle){
sqle.getStackTrace();
}
return false;
}
public List<User> getAllUsers(){
ArrayList<User> users = new ArrayList<>();
try{
......
......@@ -10,5 +10,6 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
<orderEntry type="library" name="lib1" level="project" />
</component>
</module>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment