I've 3 models [User, Role, and UserRole]
Use {ID [PK], Name, Email, Password, .....} Role {ID [PK], Name, Description, .......} UserRole {UserID [FK], RoleID [FK]}
Consider, the Role-based Authorization on controller using the [Authorize] attribute specifying that the user must be in the Administrator role to access any controller action in the class
[Authorize(Roles = "Administrator")]
public class PageController : Controller
{
// Controller code here
}
This is fine, What I need is,
Is there any way to assign my Role Collection to [Authorize] attribute? for example
I'll Fetch Assigned roles from Logged in User and store it in List. Is it possible to assign this List to [Authorize] attribute? something like as follows:
[Authorize(Roles = MyDynamicallyLoadedList)]
public class PageController : Controller
{
// Controller code here
}