I have a parent/childs relationship and both use AuthorizationRule. The save is always done on the parent. For some users, they do not have access to modify the parent but do have access to modify the childs. If the parent HasPermission returns false, it will fail on save even if the parent isn't dirty.
Public MustInherit Class EditObjectRule
Inherits AuthorizationRule
Public Sub New()
MyBase.New(AuthorizationActions.EditObject)
End Sub
Protected Overrides Sub Execute(ByVal context As AuthorizationContext)
context.HasPermission = False
End Sub
End Class
Should I look at the parent instance and see if it's dirty before doing the security check?
Public MustInherit Class EditObjectRule
Inherits AuthorizationRule
Public Sub New()
MyBase.New(AuthorizationActions.EditObject)
End Sub
Protected Overrides Sub Execute(ByVal context As AuthorizationContext)
If context.Target Is Nothing Then
context.HasPermission = False
ElseIf CType(context.Target, IBusinessBase).IsSelfDirty Then
context.HasPermission = False
Else
context.HasPermission = True
End If
End Sub
End Class
It seems weird but I don't see any other options.