Skip to content

Commit

Permalink
Use return early pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
tttzach committed Jun 18, 2020
1 parent 7cff3f4 commit 0207f37
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
String logoutUrl = userService.createLogoutURL(redirectUrl);
Pair<String, String> userInfo = new Pair<>(userEmail, logoutUrl);
sendJson(response, userInfo);
} else {
String loginUrl = userService.createLoginURL(redirectUrl);
Pair<String, String> userInfo = new Pair<>("N/A", loginUrl);
sendJson(response, userInfo);
return;
}
String loginUrl = userService.createLoginURL(redirectUrl);
Pair<String, String> userInfo = new Pair<>("N/A", loginUrl);
sendJson(response, userInfo);
}

private void sendJson(HttpServletResponse response, Pair<String, String> userInfo) throws IOException {
Expand Down
8 changes: 4 additions & 4 deletions portfolio/src/main/webapp/libraries.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ async function getLoginStatus() {
if (userEmail == 'N/A') {
const html = loginHtml(redirectUrl);
document.getElementById('login-status').innerHTML = html;
} else {
const html = logoutHtml(userEmail, redirectUrl);
document.getElementById('login-status').innerHTML = html;
document.getElementById('comments-form').style.display = "block";
return;
}
const html = logoutHtml(userEmail, redirectUrl);
document.getElementById('login-status').innerHTML = html;
document.getElementById('comments-form').style.display = "block";
}

function getEmail(json) {
Expand Down

0 comments on commit 0207f37

Please sign in to comment.