1

When I explicitly set a permission for a user in the database by running a SQL update script, the particular permission with the latest grant is not reflecting in the system. However when I recycle the IIS process or rebuild the solution, it only then seems to update.

It looks like the framework is using some kind of in-memory store for checking permissions.

Is there a "force refresh" function in ABP that I can call to refresh the in-memory store with the latest permissions from the database?

The weird thing is that when setting the permission via the front-end, the permission does work as expected without IIS recycling, so it definitely calls into some kind of function to update its cache.

aaron
  • 39,695
  • 6
  • 46
  • 102
Fanie Reynders
  • 580
  • 3
  • 16

2 Answers2

1

You can inject ICacheManager and clear the cache:

public void ForceRefresh()
{
    _cacheManager.GetUserPermissionCache().Clear();
 // _cacheManager.GetRolePermissionCache().Clear();
}
aaron
  • 39,695
  • 6
  • 46
  • 102
0

The Setting Manager caches settings on the server-side, so you should not directly change a setting value using a repository or database update query.

If your 3rd party application wants to change a setting, it should do it via WebAPI methods. So you need to create an Application Service and add a method something like ChangeSettingValue({settingName, settingValue}).

In this app service inject ISettingManager, and use ChangeSettingForApplicationAsync, ChangeSettingForTenantAsync or ChangeSettingForUserAsync methods (and sync versions) to change settings for the application, for a tenant and for a user respectively.

See the related docs > https://aspnetboilerplate.com/Pages/Documents/Setting-Management

Alper Ebicoglu
  • 8,884
  • 1
  • 49
  • 55