I need to create a workflow that allows the author to create pages in a specific path. I want to check if the user has write access to the path they have requested. The below code does not seem to work for all users. Is there another way to check user permissions?
Map<String, Object> userImpersonationMap = new HashMap<>();
userImpersonationMap.put(ResourceResolverFactory.USER_IMPERSONATION, initiator);
ResourceResolver resourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(userImpersonationMap);
Session userSession = resourceResolver.adaptTo(Session.class);
boolean canAccessPath = userSession.hasPermission(destinationPagePath, Session.ACTION_ADD_NODE);
AEM 6.5.14
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
The problem seems to be because you are using the
resourceResolverFactory.getAdministrativeResourceResolver
which has been deprecated - https://sling.apache.org/apidocs/sling7/org/apache/sling/api/resource/ResourceResolverFactory.html#g...
You can use getServiceResolver or if you need to use the user's session then you could try something as being done in below code -
Thanks
Narendra
Views
Replies
Total Likes
Hi @Brian_Vaughn
I agree with solution provided by @narendragandhi , Try to get resource resolver from service user and if you are using resource resolver to get session then get session from workflow session instead of resource resolver.
Views
Replies
Total Likes