cancel
Showing results for 
Search instead for 
Did you mean: 

Assigning access rights to the custom site page

dreambitc
Champ in-the-making
Champ in-the-making
Hey guys.
I have some custom site page, created for example by this article http://docs.alfresco.com/3.4/index.jsp?topic=%2Fcom.alfresco.Enterprise_3_4_0.doc%2Ftasks%2Fkb-code-...
In the folder, it's look like this:
1) hello.get.desc.xml
2) hello.get.head.ftl
3) hello.get.html
4) hello.get.js

What do I need:
If the user does not have access rights to the page(for example, it is not in a specific group, created by me), he should be redirected to dashboard.
It would be better:
1) If user does not have access rights to the page, alfresco will return to the standard error(lack of access, etc.)
2) If user does not have access rights to the page, insert in the head file tag <meta http-equiv="REFRESH" content="0;url=http://someurl.com">
3) If user does not have access rights to the page, from the script(hello.get.js) assign 333 to a status.code variable and status.redirect

I have no idea how to implement the first paragraph.
In the second paragraph I have problem: status, person variables are not available
The third paragraph is also not possible for the same reason that the second


Does anyone have any ideas how it should be done?
3 REPLIES 3

lementree
Champ on-the-rise
Champ on-the-rise
Hi,

To acheive this you have to create a Alfresco side Webscript that would check given user in a Group or not.
Now You can call that webscript in your .js file, then parse the Response.
like this

             var   userIsSiteCollaborator =false;
             var json = remote.call("/api/sites/" + siteId + "/memberships/" + encodeURIComponent(user.name));
       if (json.status == 200)
       {
        var obj = eval('(' + json + ')');
        if (obj)
        {
          userIsSiteCollaborator = (obj.role == "SiteCollaborator");
         
        }
       }

dreambitc
Champ in-the-making
Champ in-the-making
Hi lementree, thanks for the answer.
Okey, i have  alfresco side Webscript that would check given user in a Group or not, it is not a problem.
My problem is that i can not redirect user to dashboard, if user are not in the specific group.
In the hello.get.js I know of a user group, for example i can write model.havePermission = areUserInGroup(groupName).
I can get this variable from hello.get.html, like this: ${havePermission}, but i can not do this in hello.get.head.ftl, because i have freemarker.core.InvalidReferenceException: Expression havePermission is undefined.
If I could get access to the havePermission variable from hello.get.head.ftl, i could write this code:
<#if havePermission>
    <meta http-equiv="REFRESH" content="0;url=http://someurl.com">
</#if>
Do you have any idea how to redirect the user or better throw an exception of no right to access?

dreambitc
Champ in-the-making
Champ in-the-making
Guys, need help, can not be that no one knows how to solve this problem.