Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
S4a021 Web Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Charlie Darques
S4a021 Web Backend
Commits
67667cca
Commit
67667cca
authored
1 month ago
by
Yannis Devos
Browse files
Options
Downloads
Patches
Plain Diff
delete
parent
3e7c1db4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
WEB-INF/src/controleurs/Account.java
+1
-0
1 addition, 0 deletions
WEB-INF/src/controleurs/Account.java
WEB-INF/src/controleurs/DeleteAccount.java
+1
-2
1 addition, 2 deletions
WEB-INF/src/controleurs/DeleteAccount.java
WEB-INF/src/dao/UserDAO.java
+7
-6
7 additions, 6 deletions
WEB-INF/src/dao/UserDAO.java
with
9 additions
and
8 deletions
WEB-INF/src/controleurs/Account.java
+
1
−
0
View file @
67667cca
...
...
@@ -51,6 +51,7 @@ public class Account extends HttpServlet {
System
.
out
.
println
(
user
.
getPwd
());
System
.
out
.
println
(
user
.
getId
());
boolean
b
=
userDao
.
updatePassword
(
user
.
getUserName
(),
user
.
getPwd
(),
npwd
);
req
.
getSession
().
setAttribute
(
"user"
,
userDao
.
getUserByLogs
(
user
.
getUserName
(),
npwd
));
System
.
out
.
println
(
b
);
if
(
b
==
true
){
out
.
println
(
"<p style=\"color:lightgreen\">Your password was successfully changed"
);
...
...
This diff is collapsed.
Click to expand it.
WEB-INF/src/controleurs/DeleteAccount.java
+
1
−
2
View file @
67667cca
...
...
@@ -23,7 +23,6 @@ public class DeleteAccount extends HttpServlet {
if
(
req
.
getSession
().
getAttribute
(
"user"
)
!=
null
)
{
UserDAO
userDao
=
new
UserDAO
();
PrintWriter
out
=
res
.
getWriter
();
String
login
=
(
String
)
req
.
getSession
().
getAttribute
(
"login"
);
User
user
=
(
User
)
req
.
getSession
().
getAttribute
(
"user"
);
if
(
user
!=
null
)
{
...
...
@@ -32,7 +31,7 @@ public class DeleteAccount extends HttpServlet {
out
.
println
(
"<link rel=\"stylesheet\" href=\"css/account.css\">"
);
out
.
println
(
"<title>Account</title>"
);
out
.
println
(
"</body>"
);
if
(
userDao
.
deleteUser
(
user
.
getUserName
(),
user
.
getPwd
()
)){
if
(
userDao
.
deleteUser
(
user
)){
out
.
println
(
"Your account was successfully deleted !"
);
}
else
{
out
.
println
(
"A problem occurred while deleting your account..."
);
...
...
This diff is collapsed.
Click to expand it.
WEB-INF/src/dao/UserDAO.java
+
7
−
6
View file @
67667cca
...
...
@@ -48,18 +48,19 @@ public class UserDAO {
return
false
;
}
public
boolean
deleteUser
(
String
username
,
String
password
){
public
boolean
deleteUser
(
User
user
){
try
{
if
(
isDatabased
(
getUserByLogs
(
username
,
password
)
))
{
PreparedStatement
stmt
=
this
.
con
.
prepareStatement
(
"DELETE FROM userAccount WHERE user
name
=? AND
password
=?"
);
stmt
.
set
String
(
1
,
user
name
);
stmt
.
setString
(
2
,
password
);
if
(
isDatabased
(
user
))
{
PreparedStatement
stmt
=
this
.
con
.
prepareStatement
(
"DELETE FROM userAccount WHERE user
id
=?
AND
username
=?"
);
stmt
.
set
Int
(
1
,
user
.
getId
()
);
stmt
.
setString
(
2
,
user
.
getUserName
()
);
stmt
.
executeUpdate
();
return
true
;
}
}
catch
(
SQLException
sqle
){
sqle
.
ge
tStackTrace
();
sqle
.
prin
tStackTrace
();
}
return
false
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment