-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX , BUG , TEST ] [] AJOUTER QUELQUE UNITTEST ET L'AMELIORATION DE …
…QUELQUE FUNCTION'S
- Loading branch information
e.elhjoujy
committed
Oct 26, 2023
1 parent
ea3b614
commit 7c30da0
Showing
19 changed files
with
194 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 18 additions & 1 deletion
19
src/main/java/ma/yc/airafraik/service/impl/AccountAdminServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/ma/yc/airafraik/web/Admin/AuthController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package ma.yc.airafraik.web.Admin; | ||
|
||
import jakarta.servlet.ServletException; | ||
import jakarta.servlet.annotation.WebServlet; | ||
import jakarta.servlet.http.HttpServlet; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import ma.yc.airafraik.service.AccountService; | ||
import ma.yc.airafraik.service.impl.AccountAdminServiceImpl; | ||
|
||
import java.io.IOException; | ||
|
||
@WebServlet(name = "AuthController", value = {"/admin-login","/admin-logout"}) | ||
public class AuthController extends HttpServlet { | ||
|
||
|
||
private AccountService accountService ; | ||
private boolean isAuth ; | ||
|
||
@Override | ||
public void init() throws ServletException { | ||
this.accountService = new AccountAdminServiceImpl(); | ||
super.init(); | ||
} | ||
|
||
@Override | ||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | ||
if (req.getServletPath().equals("/admin-login")){ | ||
req.getRequestDispatcher("admin-login.jsp").forward(req,resp); | ||
}else if (req.getServletPath().equals("/admin-logout")){ | ||
req.getSession().invalidate(); | ||
resp.sendRedirect("admin-login"); | ||
} | ||
} | ||
|
||
@Override | ||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | ||
String username = req.getParameter("username"); | ||
String password = req.getParameter("password"); | ||
|
||
isAuth = this.accountService.checkLoginAccount(username, password) != null; | ||
if (isAuth){ | ||
req.getSession().setAttribute("isAuthentified",true); | ||
req.getSession().setAttribute("username",username); | ||
req.getSession().setAttribute("password",password); | ||
req.setAttribute("message","Welcome "+username); | ||
resp.sendRedirect("admin-dashboard"); | ||
}else{ | ||
req.setAttribute("message","Username or password is incorrect"); | ||
req.getRequestDispatcher("admin-login.jsp").forward(req,resp); | ||
} | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.