I have created a project based on the sample posted on the official ASP.NET site: MVC 5 with 2FA, email confirmation, password reset SMS,Two-Factor Authentication. On the other hand, although there is a separate table for Roles, I have no idea how to integrate such a kind of control which meet best my requirements. I just want to create some roles and assign them to the users. After a user login to the system, I want to check his roles and let them to reach the enabled actions for this role. How can I make such a kind of integration?
Asked
Active
Viewed 256 times
1 Answers
0
You can use the Authorize
attribute to specify the role(s) allowed to access a controller or action.
[Authorize(Roles="user, admin, another")]

Ashley Medway
- 7,151
- 7
- 49
- 71
-
Thanks for reply. But, I know this and I need a sample that give an idea for me to proceed on the right way. Any idea? – Jack Nov 16 '15 at 11:15
-
Thats not really a question for stack overflow. You can add roles to users and check if the user has a role using the code I supplied. – Ashley Medway Nov 16 '15 at 11:16
-
What about the first part (... add roles to users ...)? – Jack Nov 16 '15 at 11:44