Skip to content

add my solution#672

Open
mykhailoKrlKrk wants to merge 4 commits into
mate-academy:masterfrom
mykhailoKrlKrk:web-secure-hw
Open

add my solution#672
mykhailoKrlKrk wants to merge 4 commits into
mate-academy:masterfrom
mykhailoKrlKrk:web-secure-hw

Conversation

@mykhailoKrlKrk
Copy link
Copy Markdown

No description provided.

Driver driver = authenticationService.login(username, 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.

dont forget about contextPath

session.setAttribute("driver_id",driver.getId());
resp.sendRedirect("/index");
} catch (AuthenticationException e) {
req.setAttribute("errorMsg",e.getMessage());
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
req.setAttribute("errorMsg",e.getMessage());
req.setAttribute("errorMsg" ,e.getMessage());

protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
req.getSession().invalidate();
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.

same

Comment thread src/main/java/taxi/dao/CarDaoImpl.java Outdated
Comment on lines +214 to +215
String login = resultSet.getString("login");
String password = resultSet.getString("password");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Does it work? You from request do not pull these fields.


@Override
public Driver login(String login, String password) throws AuthenticationException {

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

image

HttpSession session = request.getSession();

Long driverId = (Long) session.getAttribute("driver_id");
if (driverId == null && allowedUrls.contains(request.getServletPath())) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

image

Comment thread src/main/java/taxi/dao/CarDaoImpl.java Outdated
Long driverId = resultSet.getObject("id", Long.class);
String name = resultSet.getString("name");
String licenseNumber = resultSet.getString("license_number");
String login = resultSet.getString("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.

You need to leave, just add these fields to the request.

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.

2 participants