This is a migrated thread and some comments may be shown as answers.

Get current user Id or Role

1 Answer 266 Views
Cloud Code
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Juan
Top achievements
Rank 1
Juan asked on 26 Nov 2014, 06:11 PM
On cloud code I need to get the current user Id (or his Role). So I can restrict certain updates to only when Role == Admin.

How to get the user info?

1 Answer, 1 is accepted

Sort by
0
Accepted
Anton Dobrev
Telerik team
answered on 28 Nov 2014, 10:24 AM
Hi Jandieg,

Thank you for posting to the Telerik Developer Forums.

I answered a similar question about how to retrieve the data of the user making the request in this forum thread. In the request.data.Principal property you have all information about the user making the request.

Note that the permissions for the content type are set to Role-based and the Administrator role is the only one able to update - you do not need to make this checks in the cloud code for the given content type.

You will notice that In the Role-based settings screen the Owner role is disabled for the create operation - since the item has no owner at the time of creation this role is irrelevant to the Create operation - that is why it is disabled.

Let me know if you have questions.

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
Cloud Code
Asked by
Juan
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Share this question
or