Authorization rule on Null value property

Authorization rule on Null value property

Old forum URL: forums.lhotka.net/forums/t/12721.aspx


jteneglio posted on Thursday, August 14, 2014

Again I may be doing something wrong but is it normal that an authorization rule on a property that is NULL does not work?   and I soon as you put something in the property it triggers?

JonnyBee replied on Thursday, August 14, 2014

Hi, 

The built-in authorization rules does NOT inspect the value - only looks at the ApplicationContext.User.IsInRole.

So is that a custom authorization rule? 

The Authz rule for AuthorizationActions.CanWriteProperty should be triggered on first attempt to set the property value.
The BuiltIn rules will instruct the object to cache the result and so the rule will not be called on later SetProperty calls for that property.

jteneglio replied on Friday, August 15, 2014

I should have added that this happens in the UI a XAML WinRT UI using a propertyInfo

<TextBox Text="Some Ttext" IsEnabled="{Binding CanWrite, ElementName=ObjectPropertytPropertyInfo}">

 <csla:PropertyInfo x:Name="ObjectPropertyPropertyInfo" Property="{Binding Object.Property}" />

 

This seems to not work when the Object.Property is null

jteneglio replied on Tuesday, August 19, 2014

and to answer your question Yes it is a custom authorization rule based on some property of the object, The property that I'm using for the CanWriteProperty is actually Null.

It seems that when Object1.Property1 = null the CanWriteProperty(Propert1property) does not fire since the property1 is null

 

Am I understanding it right?

ajj3085 replied on Wednesday, August 20, 2014

Csla will only run rules if the property value has changed from its current value;  its smart enough to know that if the property is already null and you try setting it to null again not to do anything (since the state isn't actually changing), so in your case I wouldn't expect the rule to fire.  If you need to check to see if you can write to the property you can use CanWriteProperty.

jteneglio replied on Wednesday, August 20, 2014

Right, that's what I understand, but it seems to NOT fire at all when the property the Authorization Rule is based on.  anyone experiencing this?

ajj3085 replied on Friday, August 22, 2014

I would like Johnny or Rocky to confirm this, but I think the result of the CanWriteProperty evaluation is cached by Csla.

jteneglio replied on Friday, August 22, 2014

After some tests I narrowed it down to WinRT XAML 

<TextBox Text="Some Ttext" IsEnabled="{Binding CanWrite, ElementName=ObjectPropertytPropertyInfo}">
<csla:PropertyInfo x:Name="ObjectPropertyPropertyInfo" Property="{Binding Object.Property}" />

 When Object.Property  is null this thing does not get fired from the UI

 

mbblum replied on Friday, August 22, 2014

The ElementName has a typo, extra 't' in ObjectPropertytPropertyInfo. If in actual xaml, i.e. not just error in post, may cause issues. Wouldn't expect what you describe, but never know.

Copyright (c) Marimer LLC