Skip to content

hw-jv-web-security-solution-andrey-kiyas#667

Open
andrey-kiyas wants to merge 4 commits into
mate-academy:masterfrom
andrey-kiyas:hw-jv-web-security-solution-andrey-kiyas
Open

hw-jv-web-security-solution-andrey-kiyas#667
andrey-kiyas wants to merge 4 commits into
mate-academy:masterfrom
andrey-kiyas:hw-jv-web-security-solution-andrey-kiyas

Conversation

@andrey-kiyas
Copy link
Copy Markdown

No description provided.

Driver driver = authenticationService.login(login, password);
HttpSession session = req.getSession();
session.setAttribute("driver_id", driver.getId());
resp.sendRedirect("/index");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets add contextPath

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes? Done.

protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
req.getSession().invalidate();
resp.sendRedirect("/login");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets add contextPath to all sendRedirect

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not done(
Be attentive
image

Comment on lines +35 to +44
Long userId = (Long) session.getAttribute("driver_id");
if (userId == null && alowedUrls.contains(httpServletRequest.getServletPath())) {
chain.doFilter(httpServletRequest, httpServletResponse);
return;
}
if (userId == null) {
httpServletResponse.sendRedirect("/login");
return;
}
chain.doFilter(httpServletRequest, httpServletResponse);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Long userId = (Long) session.getAttribute("driver_id");
if (userId == null && alowedUrls.contains(httpServletRequest.getServletPath())) {
chain.doFilter(httpServletRequest, httpServletResponse);
return;
}
if (userId == null) {
httpServletResponse.sendRedirect("/login");
return;
}
chain.doFilter(httpServletRequest, httpServletResponse);
Long userId = (Long) session.getAttribute("driver_id");
if (userId != null && !alowedUrls.contains(httpServletRequest.getServletPath())) {
httpServletResponse.sendRedirect("/login");
return;
}
chain.doFilter(httpServletRequest, httpServletResponse);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thank you! )

@andrey-kiyas andrey-kiyas requested a review from aaananas July 24, 2023 17:17
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
req.getSession().invalidate();
resp.sendRedirect("/login");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not done(
Be attentive
image

@andrey-kiyas andrey-kiyas requested a review from Rommelua July 25, 2023 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants