When using the UserService and updating a users permissions (ReplacePermissions) for a single node, I use the GetPermissions after performing a replace permissions function I get in the original permissions.
However these permissions did change correctly. If I recycle the AppPool, clearing the server cache the GetPermissions returns the expected result.
This is using umbraco 7.4.1, I am unsure if this is on all version 7.
The results from GetPermissions after doing the ReplaceUserPermissions are not showing the update. If I look at the user permissions in Umbraco UI it shows the update. The only way I can get the accurate results from GetPermissions is to restart the app pool.
I also tried umbraco.library.RefreshContent() to bust the cache on this. Did not work.
How can I ensure that GetPermissions is pulling the updated results without cycling the app pool?
So I've been digging through the source code, and this appears to be quite deliberate.
In the Permissions Repository, where GetPermissions eventually ends up, there is a hardcode cache expiration of 20 minutes.
So the question is, can we trigger a cache flush? I've found a class called UserPermissionsCacheRefresher, I'm just trying to figure out whether I can play with it or not :)
UserServer GetPermissions cached results
When using the UserService and updating a users permissions (ReplacePermissions) for a single node, I use the GetPermissions after performing a replace permissions function I get in the original permissions.
However these permissions did change correctly. If I recycle the AppPool, clearing the server cache the GetPermissions returns the expected result.
This is using umbraco 7.4.1, I am unsure if this is on all version 7.
I am having the same issue on version 7.2.8. Did you get this working?
Updated permissions: userService.ReplaceUserPermissions
Then
Get permissions: userService.GetPermissions
The results from GetPermissions after doing the ReplaceUserPermissions are not showing the update. If I look at the user permissions in Umbraco UI it shows the update. The only way I can get the accurate results from GetPermissions is to restart the app pool.
I also tried umbraco.library.RefreshContent() to bust the cache on this. Did not work.
How can I ensure that GetPermissions is pulling the updated results without cycling the app pool?
Same here, has this been resolved?
So I've been digging through the source code, and this appears to be quite deliberate.
In the Permissions Repository, where GetPermissions eventually ends up, there is a hardcode cache expiration of 20 minutes.
So the question is, can we trigger a cache flush? I've found a class called UserPermissionsCacheRefresher, I'm just trying to figure out whether I can play with it or not :)
So, to rebuild the cache, you just need to add:
DistributedCache cache = DistributedCache.Instance; cache.RefreshAll(DistributedCache.UserPermissionsCacheRefresherGuid, true);
where appropriate :) I do mine after I've removed the permissions :)
That worked!
Big thanks.
is working on a reply...