This is a pretty general question, actually..
I have a user class (doesn't every app ? :). Certain users can perform actions on different entities, given they have proper permissions. What is a better place to put the authorization logic (or any logic that works with 2 instances) ?
If I put it in a User class, I end up with a bunch of user.CanEditComment()
, user.CanEditMessage()
, user.CanDoSomething()
etc methods - could be a few methods for each entity that requires authorization. Seems like method clutter.
On another hand, I can put these methods in entities, like comment.CanBeEditedBy(user)
. But somehow it doesn't seem quite right either...
Any suggestions ?
Thanks !