Base solution for your next web application
Open Closed

Is there support for Data Permission? #6228


User avatar
1
suruat created

AspnetZero has support for permissions for users and role. This is useful to hide functionality from certain users or group of users (roles)).

My question is how can I use this to also hide or show data.

For example: If I have a Cities database, and I want to be able to say this user can only view these cities, or this role can only view these cities, so that when I query the DB it filters based on the roles and/or user. Is there an easy way to implement this in AspnetZero or to hook into the current perrmission system but use it for data filtering?

Thanks


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    The current permission system is what you see now. https://aspnetboilerplate.com/Pages/Documents/Authorization

    Simple implementation: The user or role is associated with the city. You can get the city information of the current user and role after the authorization check is passed, and then filter the city data.

    I think the code should not be too complicated after optimization.

  • User Avatar
    0
    suruat created

    I am not sure I totally understand what you mean by "The user or role is associated with the city."

    Do you have any simple examples of this?

  • User Avatar
    0
    maliming created
    Support Team

    https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.Zero.Common/Authorization/Users/UserRole.cs#L11

    Just like UserRole, you can get the city assigned to it based on the current user and its role.