Skip to content

Commit

Permalink
Fix for improper redirect between home and index
Browse files Browse the repository at this point in the history
  • Loading branch information
ALEEF02 committed Nov 11, 2022
1 parent 04ad967 commit 7703efd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion MavenBack/src/main/java/ppp/auth/AuthServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr
}

// At this point we know that this person is that of the email provided. Setup account if it doesn't exist now.
response.setStatus(200);
response.getWriter().println("huh. That worked. now what?");
request.getSession().setAttribute("email", email);
request.getSession().setMaxInactiveInterval(-1);
response.setStatus(200);
OUser user = CUser.findByEmail(email);
Date now = new Date();

Expand Down
28 changes: 27 additions & 1 deletion MavenBack/src/main/webapp/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,37 @@
<link rel="stylesheet" type="text/css" href="baseStyle.css">
<link rel="stylesheet" type="text/css" href="homeStyle.css">
<title>PingPongPage</title>

<script>

window.addEventListener('load', function() {

var login = new XMLHttpRequest();
login.onreadystatechange = function(){
if (login.readyState == 4) {
if (login.status == 200) {
// User is already logged in
var user = JSON.parse(login.responseText);
var userButton = document.getElementById("userButton");
userButton.innerHTML = "Hi, " + user.username + " :)";
userButton.href = "/logout";
} else {
// User is not logged in
var userButton = document.getElementById("userButton");
userButton.innerHTML = "Login";

}
}
}
login.open('GET', '/api/users');
login.send();
});
</script>
</head>
<body>
<div class = "navBar" role="navigation" aria-label="Main">
<a href = "#" class = "left" style="color: #f95a42;">The Ping Pong Page</a>
<a id="userButton" href="/login">Login</a> <!--Leads to user page to display user name, stats, etc.-->
<a id="userButton" href="/login">...</a> <!--Leads to user page to display user name, stats, etc.-->
<a href = "/games">Manage Your Games</a> <!--Leads to seprate page for ppl to register their games-->
</div>
<div class = "welcomeContainer">
Expand Down

0 comments on commit 7703efd

Please sign in to comment.