Adding Basic Access Control
Bloqs provides a simple way to set up basic access control for your application. This lets you manage tenants and users through the app UI.
Example
var accessControl = new MenuItem { Name = "Access control" };
builder.AddBasicAccessControl<User, Tenant>(globalStorage, accessControl);Explanation
.AddBasicAccessControl<User, Tenant>– Enables basic tenant and user management.User– Your own class that inherits from the Bloqs baseUserclass (or the class itself).Tenant– Your own class that inherits from the standard BloqsTenantclass (or the class itself).globalStorage– A global data storage where tenants and users are stored and managed.accessControl– A menu item in the left drawer under which the access control pages will appear.
Sample User Class
Here’s an example of creating your own User class by inheriting from the Bloqs base user type:
using Bloqs.App.Engine.AccessControl;
namespace Templates.SampleApp.Models.Global;
public class UserAccount : User
{
public bool CanCreateActivities { get; set; } = true;
}This custom UserAccount class extends the default Bloqs User and adds a simple property for permissions.
Important Notes
Global storage is required because tenants and users must be managed centrally.
The relationship between tenants and users (for example, which users belong to which tenants) is up to you to implement.
This feature provides the basic UI and CRUD pages needed to manage tenants and users, but you can extend it with your own rules and authorization logic.
Last updated