Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SAE4.A02.1
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
Maxime Gosselin
SAE4.A02.1
Commits
7be2a4fa
Commit
7be2a4fa
authored
2 months ago
by
Maxime Gosselin
Browse files
Options
Downloads
Patches
Plain Diff
Authent gère les erreurs
parent
194fd5da
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
WEB-INF/src/controleur/Authent.java
+9
-5
9 additions, 5 deletions
WEB-INF/src/controleur/Authent.java
with
9 additions
and
5 deletions
WEB-INF/src/controleur/Authent.java
+
9
−
5
View file @
7be2a4fa
...
@@ -34,18 +34,19 @@ public class Authent extends HttpServlet {
...
@@ -34,18 +34,19 @@ public class Authent extends HttpServlet {
}
}
hashedPassword
=
sb
.
toString
();
hashedPassword
=
sb
.
toString
();
}
catch
(
NoSuchAlgorithmException
e
)
{
}
catch
(
NoSuchAlgorithmException
e
)
{
throw
new
RuntimeException
(
e
);
req
.
setAttribute
(
"error"
,
"Problème lors du hashage du mot de passe"
);
req
.
getRequestDispatcher
(
"/WEB-INF/vue/error.jsp"
).
forward
(
req
,
resp
);
return
;
}
}
String
vue
=
"WEB-INF/vue/login.jsp"
;
String
vue
=
"WEB-INF/vue/login.jsp"
;
boolean
dispatch
=
true
;
switch
(
action
)
{
switch
(
action
)
{
case
"login"
:
case
"login"
:
if
(
daoUser
.
checkUser
(
username
,
hashedPassword
))
{
if
(
daoUser
.
checkUser
(
username
,
hashedPassword
))
{
dispatch
=
false
;
req
.
getSession
().
setAttribute
(
"username"
,
username
);
req
.
getSession
().
setAttribute
(
"username"
,
username
);
resp
.
sendRedirect
(
"navigation?page=accueil"
);
resp
.
sendRedirect
(
"navigation?page=accueil"
);
return
;
}
else
{
}
else
{
req
.
setAttribute
(
"error"
,
"Identifiant ou mot de passe incorrect"
);
req
.
setAttribute
(
"error"
,
"Identifiant ou mot de passe incorrect"
);
}
}
...
@@ -56,16 +57,19 @@ public class Authent extends HttpServlet {
...
@@ -56,16 +57,19 @@ public class Authent extends HttpServlet {
String
lastname
=
req
.
getParameter
(
"lastname"
);
String
lastname
=
req
.
getParameter
(
"lastname"
);
try
{
try
{
dispatch
=
false
;
daoUser
.
create
(
new
User
(
username
,
hashedPassword
,
firstname
,
lastname
));
daoUser
.
create
(
new
User
(
username
,
hashedPassword
,
firstname
,
lastname
));
req
.
getSession
().
setAttribute
(
"username"
,
username
);
req
.
getSession
().
setAttribute
(
"username"
,
username
);
resp
.
sendRedirect
(
"navigation?page=accueil"
);
resp
.
sendRedirect
(
"navigation?page=accueil"
);
return
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
req
.
setAttribute
(
"error"
,
"Nom d'utilisateur déjà pris"
);
req
.
setAttribute
(
"error"
,
"Nom d'utilisateur déjà pris"
);
vue
=
"WEB-INF/vue/signin.jsp"
;
vue
=
"WEB-INF/vue/signin.jsp"
;
}
}
break
;
break
;
default
:
req
.
setAttribute
(
"error"
,
"Ne changez pas l'url vous même!"
);
req
.
getRequestDispatcher
(
"/WEB-INF/vue/error.jsp"
);
}
}
if
(
dispatch
)
req
.
getRequestDispatcher
(
vue
).
forward
(
req
,
resp
);
req
.
getRequestDispatcher
(
vue
).
forward
(
req
,
resp
);
}
}
}
}
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