Custom authorize using MVC
Posted
by
Karsten
on Stack Overflow
See other posts from Stack Overflow
or by Karsten
Published on 2012-10-25T16:56:58Z
Indexed on
2012/10/25
17:00 UTC
Read the original article
Hit count: 225
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?
© Stack Overflow or respective owner