In my MVC5 project, admin can create lessons in a control panel and the lessons are stored in the database (currently there is only 2 lessons for now). On the other hand, I can create some roles for these lessons i.e. CanCreateMathHomework, CanCreateChemistryHomework so that only the teachers of the related lesson can publish homework for the related lesson by using ASP.NET Identity. Until now everything works perfectly and the teachers can publish homework of their lesson.
LessonController:
[Authorize(Roles = "CanCreateMathHomework")]
public ActionResult CreateMathHw()
{
//code omitted for brevity
}
[Authorize(Roles = "CanCreateChemistryHomework")]
public ActionResult CreateChemistryHw()
{
//code omitted for brevity
}
However, I want to create a flexible permission mechanism that let the teachers of the newly created lessons to publish their homeworks without creating the new roles in the database or new Actions in the Controller. What I want to perform is that:
1) Admin will continue to create new lessons and teacher of the lesson then keep them in the database as ever before.
2) Admin give the permission to the teacher of newly created lesson so that he or she will be able to publish hw of his or her lesson as the other teachers.
3) There would be no need to create new Action methods in the Controller and everything should be done without needing the software developer.
But how? Is it possible? If so, can a global role and Action method be used in order to perform this? I am really very confused and any helps would be appreciated. Thanks.