Forum Discussion
When you use the "rest" context object, the call is made as the user viewing the page. So when "jvcd" hits the page as a regular user, it's making a REST API call as "jvcd" to add the "Administrator" role to himself. Only administrators can grant the administrator role, so the request is getting rejected because "jvcd" doesn't have sufficient permission.
I'm curious why this approach is necessary. Why not just grant the role via the community admin? I'd advise against trying to assign the Administrator role via Freemarker components due to the security implications it has. What happens if one day you no longer want "jvcd" to be an Administrator? Removing the role via the admin panel isn't enough, because "jvcd" can just login again to get the "Administrator" role again. You'd have to go through the entire process of making and deploying Studio changes in order to effectively remove the role from this user.
Related Content
- 4 years ago
- 10 years ago