Message Boards

What is the variable/macro for sign_out in freemarker theme ? Liferay 7.1CE

thumbnail
Achmed Tyrannus Albab, modified 4 Years ago.

What is the variable/macro for sign_out in freemarker theme ? Liferay 7.1CE

Regular Member Posts: 158 Join Date: 3/5/10 Recent Posts
Hi,
I am trying to add checking to the theme template using freemarker.
Script are as follows :


<#if is_signed_in>
    <#assign usrRoles = user.getRoles()>
    <#list usrRoles as usrRole>
        <#if usrRole.getName() == "Zorro">
            //run a logout using freemarker
        </#if> 
    </#list>     
</#if>


If you have to ask, im trying to allow userRole Zorro to only access my form page via AutoLogin feature.
Once done, this user will be redirected to some page which will detect if he is with Zorro role, page will log out.

On the other hand, if you know how to disable the top and side menu for user with this role, please do share as well.

Thanks in advance.
thumbnail
Olaf Kock, modified 4 Years ago.

RE: What is the variable/macro for sign_out in freemarker theme ? Liferay 7

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
Achmed Tyrannus Albab:

If you have to ask, im trying to allow userRole Zorro to only access my form page via AutoLogin feature.
Once done, this user will be redirected to some page which will detect if he is with Zorro role, page will log out.
I'm not sure this is a good choice: If a user is logged in, they could (technically) also go through the JSON API, where they have all permissions that their roles provide them.
Protecting a page is one thing, protecting content or disallowing users certain operations through hiding of UI controls is another. Typically page protection (what you ask for) is not enough - unless you do it here for convenience, not for security reasons.
thumbnail
Andrew Jardine, modified 4 Years ago.

RE: What is the variable/macro for sign_out in freemarker theme ? Liferay 7

Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hi Achmed,I am in full agreement with Olaf -- if you think of the portal as a Room, it is a room with many doors. Your solution will only provide a lock for one of them. I would be inclined to do any detection and custom logic either in the AutoLogin class, or in a PostLogin hook, or a ServletFilter etc. -- basically, avoid using a "page" to try to run this logic because it sounds like you don't want this scenario to allow access to the portal at all. This way, whether you log in via browser, or leverage a tool like Postman, or run a curl operation, those classes should be invoked, and your logic applied. 
thumbnail
Achmed Tyrannus Albab, modified 4 Years ago.

RE: What is the variable/macro for sign_out in freemarker theme ? Liferay 7

Regular Member Posts: 158 Join Date: 3/5/10 Recent Posts
Hi Olaf & Andrew,Thanks for the quick reply.
Thing is i'm playing around with the features to see what it can or cannot do.
I have already tried restricting the role User (default for authenticated user) by removing all rights, in a way hoping this user cant do much when its logged in. I couldn't find more documentation on this (or haven't yet) so i need to do my own testing.

So if we can move on from there,  I've also tried changing the success page to something like https://www.liferay.com/c/portal/logout which of course didn't work as well. Puzzles me that the page doesn't seem to actually load but changed static-ly instead (not sure how to say this better).

So yeah, if you kind sirs would help, it would be nice to have the freemarker do logout variable (if any) .

Or  if you could help me on the trailing question on how to remove the top and side panel (via .ftl theme template) would be great. I tried to hide  <@liferay.control_menu /> but some other part is still pushing the view down via css. I tried changing in init.ftl as well so it doesnt add certain logged in CSS but to no avail. 

And yes by removing all roles rights from the user also doesnt remove the top and side bad once user is logged in.
Lastly, in case you didnt notice im trying to do this without using hooks or making any changes via source. More looking at it as configuration or theme development, to see if its feasable or not.

​​​​​​​Regards,
thumbnail
Andrew Jardine, modified 4 Years ago.

RE: What is the variable/macro for sign_out in freemarker theme ? Liferay 7

Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Thing is i'm playing around with the features to see what it can or cannot do.

That's cool -- if there are a set of specific requirements your assessing the platform for, it might be beneficial to share them with us as we can help you understand both whether or not Liferay can handle it out of the box,  and also possibly point you to the part of the application that would be used to manage it. 
So if we can move on from there,  I've also tried changing the success page to something like https://www.liferay.com/c/portal/logout which of course didn't work as well. Puzzles me that the page doesn't seem to actually load but changed static-ly instead (not sure how to say this better).


That won't work because that particular URL you are using is wired to a struts action that simply terminates the session (logging out the user). Once it is done, it routes the user to the default.logout.page (you can set this in the Control Panel > Configuration > Instance Settings section, or in the portal-ext.properties file -- though I would recommend the control panel as the value there overrides anything in the properties file). That can be set to whatever page you like (that you create) such as a /goodbye page. If you don't specify a page in that setting though, the system will automatically route you to the default home page. Portal level struts actions can be easily identified because they start with /c and, for all Liferay ones at least also contain a sub path of /portal .. hence /c/portal. The concept of pages in Liferay is very much a "virtual" thing since there is no physical file representing a page -- so we do talk about pages, but they are basically as much "routes" as they are pages. 

Or  if you could help me on the trailing question on how to remove the top and side panel (via .ftl theme template) would be great. I tried to hide  <@liferay.control_menu /> but some other part is still pushing the view down via css. I tried changing in init.ftl as well so it doesnt add certain logged in CSS but to no avail. 

Are you creating your own custom theme? By default the left bar is hidden unless you pull it in (at which point it will default to showing until you hide it again of course). The top bar is another story. Normally what I do for that one, in my custom theme, is change the CSS to put it off screen (negative position) and then in my own header I introduce a control that can be used to pull in down. That control is what I scope so that only users in certain roles have the trigger to do this. This way, the top and left bars are never visible unless, say, an administrator chooses to reveal them. But even if he/she does, it only makes them visible to the admin. 

Lastly, in case you didnt notice im trying to do this without using hooks or making any changes via source. More looking at it as configuration or theme development, to see if its feasable or not.


There is SO MUCH that Liferay can do out of the box, and in fact, there are usually many ways to achieve a specific goal. I would say tht if you can make something happen, cleanly, without having to extend of override something in the core product, that is you best approach of course as it simplifies the upgrade path to newer versions etc. With that said, part of what makes Liferay so powerful, imho, is that you can change almost anything that comes out of the box to meet your needs. Hooks and Modules are incredibly powerful, so I wouldn't rule them out completely. 

As I said above, maybe a list of requirements that you are using to assess the product is the best way to answer your questions. Like the logout scenario, you may end up asking how to do something a certain way because it feels right, but someone with more experience with the product (monitoring these forums) may point you in a different direction to achieve the results you need.