How can I authorize users based on a posted integer? The Showproduct action shows the product itself. it should only be visible if logged in user owns the product. This is how the Index looks like
//Only accessible if the posted ProductID belongs to a specific artist.
[customauthorization]
public ActionResult ShowProduct(int ProductID)
{
return view();
}
Every product belongs to an artist. The ArtistID is set in the profilebase.
I have got 2 user roles, 'Normal' and 'Admin'. Normal users can only access the ActionResult ShowProduct if the product is theirs. everything is stored in a database.
I've tried to use custom authorization for this but I can't access the ProductID via the authorization class. Nothing seems to work although I am sure more people are facing this problem. Can anybody help me?
ProductCategory
or aUserRole
and authorise actions on that. Also it's not clear what kind of an action is theProduct
, did you mean something likeRemove
orEdit
instead? – oleksii 13 mins ago