portfolio/src/main/webapp/comments.js
// authenticated, displays user's email in DOM
authenticated, displays user's email in DOM
authenticated displays user ' s email in DOM
function addActionButtonsBasedOnAuthState(authState) {
  const authDiv = document.getElementById('auth');
  if (authState.authenticated === true) {
    const userEmailElement = document.createElement('p');
    userEmailElement.innerText = 'Hello, ' + authState.username + ' !';
    authDiv.appendChild(userEmailElement);
    authDiv.appendChild(createLinkButton('Log out', authState.logoutUrl));
  } else {
    const infoText = document.createElement('p');
    infoText.innerText = 'Log in to leave a comment';
    authDiv.appendChild(infoText);
    authDiv.appendChild(createLinkButton('Log in', authState.loginUrl));
  }
}
function addActionButtonsBasedOnAuthState ( authState ) { const authDiv = document . getElementById ( 'auth' ) ; if ( authState . authenticated === true ) { const userEmailElement = document . createElement ( 'p' ) ; userEmailElement . innerText = 'Hello, ' + authState . username + ' !' ; authDiv . appendChild ( userEmailElement ) ; authDiv . appendChild ( createLinkButton ( 'Log out' , authState . logoutUrl ) ) ; } else { const infoText = document . createElement ( 'p' ) ; infoText . innerText = 'Log in to leave a comment' ; authDiv . appendChild ( infoText ) ; authDiv . appendChild ( createLinkButton ( 'Log in' , authState . loginUrl ) ) ; } }
authenticated, displays user's email in DOM
authenticated displays user ' s email in DOM