Progress will discontinue Telerik Platform on May 10th, 2018. Learn more

How to Determine the User Account Making the Request in Business Logic

Environment

Service Business Logic
Feature Cloud Code for Data, Cloud Functions

Description

Often you may need to check the user account properties of the current user making a request to a content type or a Cloud Function.

Solution

You can get information about the account but only if the request is made by an authenticated user as opposed to an anonymous user. To do so, check for the information contained in the principal.data object of the request parameter.

Example:

if (request.principal.type === 'user') {
    var currentUserObject = request.principal.data;
    console.log("The current user username is: " + currentUserObject.Username);
} else if (request.principal.type === 'anonymous') {
    console.log("The current request is made anonymously. No data for the current user.");
} else {
    console.log("The current request is made from the Telerik Platform UI");
}

See Also

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.