(26/30) Let's Learn Blazor Together: Assign Roles to Users
Yesterday, the `CRUD` functions for roles were completed. Next, we need to assign roles to users.
Yesterday, the `CRUD` functions for roles were completed. Next, we need to assign roles to users.
In some cases, it is necessary to dynamically execute C# code during program runtime. For example, storing frequently changing algorithms in a configuration file and reading and executing them from the configuration file during runtime. C# scripts can be used to accomplish these tasks.
First, add a `ViewModel` to carry role data, because the upcoming permissions will be judged based on roles.
The day before yesterday, we added content in `Blog.razor` to display both authorized and unauthorized views. However, if the unauthorized content to be displayed is the same across the system, writing it in every component would be a waste of time. We can use `App.razor` to handle unified presentation.
Earlier, we mentioned `UserAuthentication()` and `UserAuthorization()`. The difference is that the former is used to verify who the user is, and the latter determines what the user can do.
Recently, the department has been promoting micro frontends, requiring the division of multiple sub-applications by functionality. The main application often encounters loading failures during the loading process.
Yesterday's authentication only targeted the Identity system and did not include our logs.
Today, we'll implement the authentication part.
Currently, containers and Docker remain the hottest topics in the tech field. The containerization of stateless services has become an irreversible trend, while also sparking a heated debate: `Should MySQL databases be containerized?`
When developing a system, logging is very important. It hasn't been mentioned before; the author only recently thought of it, so let's implement it!