cancel
Showing results for 
Search instead for 
Did you mean: 

change user role on login

nancyaggarwal
Champ in-the-making
Champ in-the-making
hi,

I have a query regarding user role in alfresco.

For example: Let there is one user "test". He logs into alfresco and he lands on his user dashboard. Now he wants to create a folder in global repository and for that he requires the role or permission. So, i want to ask is there any way by which i can change his role or give permission to that user on a folder without admin rights.


Thanks
Nancy
4 REPLIES 4

romschn
Star Collaborator
Star Collaborator
What I understand from your post is that - once a user logs in, you want to allow him to create a folder at a location inside repository where he does not have permission. If this understanding is correct, then once user logs in, you can have a web script where in you can write folder creation logic running as a system user and set back the current user as running user.

Hope this helps.

Hi Ramesh,

Yes your understanding is correct. But i don't want to do it with a webscript. Is there any other way?



Regards
Nancy

Another option is to find out a suitable place, to include the execution logic for running as a system user and assigning permission, in the existing out-of-the-box web scripts call that gets triggered once a user logs in. Anyways, you will have to extend them to add your logic.
Hence, In my opinion, instead of doing that, writing your own web script and then calling it after login would be a much cleaner implementation.

Hope this helps.

As suggested by you, I have written below we script

AddUserToGroup.get.desc.xml

<webscript>

  <shortname>AddUserToGroup</shortname>

  <description>AddUserToGroup</description>

  <url>/auth/AddUserToGroup</url>

  <format default="html">argument</format>

  <authentication>user</authentication>

  <transaction>required</transaction>

</webscript>


AddUserToGroup.get.js

var user = people.getPerson(user);

var group = people.getGroup("GROUP_test");



if (user == undefined)

{

   status.code = 404;

   status.message = "User not found";

   status.redirect = true;

}

else if (group == undefined)

{

   status.code = 404;

   status.message = "Group not found";

   status.redirect = true;

}

else

{

   people.addAuthority(group,user);

}


AddUserToGroup.get.html.ftl

<html>

   <head>

      <title>Groups</title>

   </head>

   <body>

      User assigned to group

   </body>

</html>



but the above web script is giving me 500 error as
Exception: org.mozilla.javascript.EcmaError - TypeError: Cannot find function getGroup in object Node Type: {http://www.alfresco.org/model/content/1.0}person, Node Aspects:





Regards,
Nancy