Skip to content

Commit

Permalink
Requested Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ChisomOkwor committed Jun 25, 2020
1 parent 60f24ec commit b2c0da7
Show file tree
Hide file tree
Showing 4 changed files with 390 additions and 394 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
UserData newData = new UserData(id, name, comment, date);
data.add(newData);
}

response.setContentType("application/json;");

Gson gson = new Gson();
Expand All @@ -72,7 +72,7 @@ public static class UserData {
String name;
String comment;
Date date;

UserData(long id, String name, String comment, Date date) {
this.id = id;
this.name = name;
Expand Down Expand Up @@ -108,7 +108,7 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr

// Redirect back to the HTML page.
response.sendRedirect("/index.html");
} else {
} else {
throw new IllegalArgumentException("Login to post comments.");
}
}
Expand All @@ -118,7 +118,7 @@ private int getIntParameter(HttpServletRequest request, String name, int default
if (value == null) {
return (defaultValue);
}

return Integer.parseInt(value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@ public class LoginStatusServlet extends HttpServlet {
private final UserService userService = UserServiceFactory.getUserService();
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("text/html");

String urlToRedirectToAfterUserLogsOut = "/";
String logoutUrl = userService.createLogoutURL(urlToRedirectToAfterUserLogsOut);

String urlToRedirectToAfterUserLogsIn = "/index.html";
String urlToRedirectToAfterUserLogsIn = "/";
String loginUrl = userService.createLoginURL(urlToRedirectToAfterUserLogsIn);

Boolean isUserLoggedIn = userService.isUserLoggedIn();
boolean isUserLoggedIn = userService.isUserLoggedIn();

LoginData userLoginData = new LoginData(loginUrl, logoutUrl, isUserLoggedIn);
response.setContentType("application/json");

Gson gson = new Gson();
response.getWriter().println(gson.toJson(userLoginData));

Expand All @@ -53,7 +52,7 @@ public static class LoginData {
String logoutUrl;
boolean isUserLoggedIn;

LoginData(String loginUrl, String logoutUrl, Boolean isUserLoggedIn) {
LoginData(String loginUrl, String logoutUrl, boolean isUserLoggedIn) {
this.loginUrl = loginUrl;
this.logoutUrl = logoutUrl;
this.isUserLoggedIn = isUserLoggedIn;
Expand Down
Loading

0 comments on commit b2c0da7

Please sign in to comment.