CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Authorization rule on Null value property

    rated by 0 users
    Not Answered This post has 0 verified answers | 8 Replies | 1 Follower

    Top 150 Contributor
    60 Posts
    Jean posted on Thu, Aug 14 2014 8:25 AM

    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?

    All Replies

    Top 10 Contributor
    2,279 Posts
    JonnyBee replied on Thu, Aug 14 2014 10:59 PM

    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.

    Jonny Bekkum, Norway CslaContrib Coordinator

    Top 150 Contributor
    60 Posts
    Jean replied on Fri, Aug 15 2014 6:59 AM

    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

    Top 150 Contributor
    60 Posts
    Jean replied on Tue, Aug 19 2014 10:52 AM

    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?

    Top 10 Contributor
    4,106 Posts
    Andy replied on Wed, Aug 20 2014 11:37 AM

    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.

    Top 150 Contributor
    60 Posts
    Jean replied on Wed, Aug 20 2014 2:12 PM

    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?

    Top 10 Contributor
    4,106 Posts
    Andy replied on Fri, Aug 22 2014 7:39 AM

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

    Top 150 Contributor
    60 Posts
    Jean replied on Fri, Aug 22 2014 8:24 AM

    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

     

    Top 150 Contributor
    50 Posts
    mbblum replied on Fri, Aug 22 2014 1:16 PM

    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.

    Page 1 of 1 (9 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems