Hey guys,
I have been trying to search for “Get current user roles block within User api” using Backendless Navigator and it didn’t return any results. What I was looking for is this:
Is there any documentation on the “Get current user roles” block within User api?
The block returns a list of role names (as string values) the currently logged in user has. The roles will be a combination of system roles and any custom roles assigned to the user.
I presume you have to connect that block(get current user roles) with the "in list ‘getCurrentUserRoles list block’ find ‘first’ occurrence of item ‘roleName text block’ " block.
But what would be returned if the item(role) is not in the list?
A user without roles cannot exist. As one of the example, if it is a non-registered user he will have the role “NotAuthenticatedUser” and the role of the key that was used in the request.
Please have a look at this documentation, it will give you a better understanding of the Security and User Roles available in Backendless: https://backendless.com/docs/dotnet/users_user_roles.html
I think there is a misunderstanding here, I’m trying to find out if a specific role is assigned to the current loggedin user for Authorization purposes, so if I use the “in list __ find first occurrence of item __” and the specified roles is there then the user will be authorized if not they won’t, but what would be returned from the list search if the specified role is not in the list?
“in list __ find first occurrence of item __” - returns the position at which a given element can be found in the array and “0” if not found.
But to find out if there is a role on the list I recommend you use this block