0

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

1 Answers1

0

Terms of Use and their acceptance is a feature in Liferay that does not require any programmatic development.

In 7.4, go to Control Panel / Configuration / System Settings and type "Terms" in the search bar. You'll find "Web Content", and in the "Virtual Instance Scope" Web Content section, at the bottom, you'll find two input fields to enter a groupId and an articleId. Those are the terms that you'd like to show (referring to a Web Content Article (articleId) of a specific Site (groupId))

Acceptance will be stored in the database, and access to the system is blocked if the terms are not accepted.

Terms of use can be disabled through a portal.properties setting named terms.of.use.required, which defaults to true.

In older versions, all of this configurations was in portal.properties - to be overloaded in portal-ext.properties. I can't recall when the configuration moved from properties to system settings.

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
  • Thanks Olaf for your reply but I am using liferay 5.* version and I am not see such configuration settings. Although I also wants to learn how to add customized page which provides some text and a single button that covers entire screen. – user18781702 Oct 26 '22 at 10:39
  • It's quite significant information that you're using software that is from 2008/2009. Back then, you still have a chance that this can be configured in portal-ext.properties. Open the portal.properties of your version and "Ctrl+F term". But actually, the proper answer is: Upgrade. You're missing out on quite some security updates, new features and better technology. – Olaf Kock Oct 26 '22 at 11:39