My requirement is that after successful login into the portal user should redirect to a page containing company's terms and conditions text with an "Accept" Button. User must click on the Accept button if he wants to access the application. Without clicking on the accept button user should not be able to access the application.
So what I want is that after clicking on the "Accept" Button a value must set in the session attribute (for eg. TERMS_ACCEPTED=true , something like that). The user cant avoid the Accept Button on refreshing the browser as well.
In portal_normal.vm I have set the below condition to get terms page on login with accept button.
#if (!$is_login_page)
#if (!$is_signed_in)
<script>
window.location= '/c/portal/login';
</script>
#else
#if(!$is_accepted)
<p id="terms-para" style=""> CLICK THE ACCEPT BUTTON TO PROCEED. </p>
<button id="accept-button">Accept</button>
<div id ="terms-footer" ></div>
</div>
<script>
var acceptButton = document.getElementById("accept-button");
acceptButton.addEventListener('click', ()=>{
#set ($is_accepted = $request.getSession().setAttribute("TERMS_ACCEPTED", true))
window.location.reload();
});
</script>
I tried this way but on refreshing the page the session attribute is set to true without user being clicked on accept button.
The approach works well with cookie. But cookie can be edited in the browser and I want to achieve it through session only.
Can it be achieved through portal_normal.vm or I should make another .jsp page and set it as a default landing page. If later is the solution and don't know how to implement this. Please help