-1

My question is about design, Let's say that I built a parking system. This system has classes for entries, cars, slots, tickets ... and everything you can imaging in a parking lot, Obviously this system need's someone to control it, or maybe multiple people will work on it. I need a class diagram for User, Admin ext, I prefer if i have the ability to easily create new types of users that has different privileges. I tried the strategy pattern where every privilege has an allowed and not allowed strategy, and when I want to create a new type of user, I give it the appropriate strategies. I'm not sure if this is a good solution, can someone make a class diagram for the user, maybe using the strategy pattern, but feel free to use the solution that you think is more suitable for this problem. For the rest of the app use an abstraction, I don't think that it's important. I just need the user part.

also I want it to be like linux, You log in with your password as an admin or something else.

  • 1
    You mentioned your question, but you forgot to ask it. – mkrieger1 Sep 28 '22 at 19:52
  • I think you may want to review [this](https://stackoverflow.com/help/on-topic) help doc. As it stands this is opinion based and typically "will you code x for me" questions are discouraged. – War10ck Sep 28 '22 at 19:54
  • I don't want you to code for me I just need some advice or even some articles will be good enough, I just need the structure and the direction, also it's for educational purpose. – Zine eddine Boumaza Sep 29 '22 at 08:30

1 Answers1

0

It is possible to use role based authorization. So you can mark your methods by some attribute which will allow to be used by user with some roles.

So, it would look like this if you use ASP.NET Core:

[Authorize(Roles = "Administrator")]
public class AdministrationController : Controller
{
    public IActionResult Index() =>
        Content("Administrator content");
}

So the above method can be reached only user who has Administrator role.

Read more about Role-based authorization in ASP.NET Core here

StepUp
  • 36,391
  • 15
  • 88
  • 148