Custom authorize using MVC
- by Karsten
Im working a bit with MVC. I need to know something about roles when using the same controller for several users getting and showing pictures.
I need to show pictures, but sometimes these pictures should only be shown for those who created them. So now when using the Authorize attribute and if picture and username match thrue my databse I could ofcause use this to make a match. I could ofcause make a match method in the controller.
[Authorize]
controllGetPicture(Picture ID){
getSomepicture..
return picture
}
DB relations
Relations
[User] <- [Pictures]
ID FK_UserID
Im thinking about just getting the User ID and compare with the Picture FK_UserId at the picture but I think it could be smarter. How?