Authorization for information only

Posts   
 
    
neilx
User
Posts: 267
Joined: 02-Nov-2007
# Posted on: 11-Jun-2011 22:18:34   

2.6.10.809 (SD.LLBLGen.Pro.LinqSupportClasses.NET35.dll) 2.6.10.930 (SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll) 2.6.10.917 (SD.LLBLGen.Pro.DQE.SqlServer.NET20.dll)

3.1.1.518 (SD.LLBLGen.Pro.DQE.SqlServer.NET20.dll) 3.1.1.518 (SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll 3.1.11.221 (SD.LLBLGen.Pro.DQE.SqlServer.NET20.dll)

It looks like Authorizer Hint methods either clear the entity or throw it away. In the circumstances I have I actually want the hint to do nothing. Our clients contract information. If the entity in question is contracted, I will want the ui to show it differently (maybe in bold, or with a link to more details).

It looks like the Authorizer can easily calculate whether the entity is contracted or not, but I want the hint to do nothing. That would allow me to call CanLoadEntity() and set my ui accordingly. With .ClearData and .ThrowAway data only, I can't use CanLoadEntity() as a notification without actually affecting the entity.

I could probably get the CanLoadEntity() to set a custom IsContracted property and return true always, thus bypassing the hint method, but is that the best way?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-Jun-2011 22:42:22   

Hi neilx,

I think you are looking in the wrong place. I mean, you don't want to restrict whether the user load an entity, and the Authorizer does just that. What you want is to know if the entity is contracted, and the best place to place that depends on how you are calculating that (i.e. how do you know if the entity is contracted?).

The natural option is to write a custom property or method that calculates this for you.

public bool IsContracted
{
     get{ ... }
}

Of course you can force the Authorizer in some way to tell you that, but IMHO that is the wrong place.

David Elizondo | LLBLGen Support Team
neilx
User
Posts: 267
Joined: 02-Nov-2007
# Posted on: 13-Jun-2011 07:43:20   

You are right. I guess I just got over excited about Authorizers:-)

"To a man with a hammer, everything looks like a nail."-Mark Twain