Replies: 1 comment
-
|
Hi. A mwe works correctly. Here's the code I'm using: using Csla;
using Csla.Configuration;
using Csla.Rules;
using Csla.Rules.CommonRules;
using Microsoft.Extensions.DependencyInjection;
using var sp = new ServiceCollection()
.AddCsla()
.BuildServiceProvider();
var appContext = sp.GetRequiredService<ApplicationContext>();
Console.WriteLine(Csla.Rules.BusinessRules.HasPermission(appContext, AuthorizationActions.GetObject, typeof(TestList)));
[Serializable]
public class TestList : BusinessListBase<TestList, Test>
{
[ObjectAuthorizationRules]
public static void AddObjectAuthorization()
{
BusinessRules.AddRule(typeof(TestList), new IsInRole(AuthorizationActions.GetObject, "Krznbf"));
}
}
[Serializable]
public class Test : BusinessBase<Test>;I've added CSLA 8.2.9 and the Can you give more information about the calling code and |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
CSLA 8 get the error message when calling HasPermission. Here's the HasPermissioin method being called in CSLA:
//
// Summary:
// Checks per-type authorization rules.
//
// Parameters:
// applicationContext:
//
// action:
// Authorization action.
//
// objectType:
// Type of business object.
public static bool HasPermission(ApplicationContext applicationContext, AuthorizationActions action, Type objectType)
{
if (applicationContext == null)
{
throw new ArgumentNullException("applicationContext");
}
Here's the calling function from the business object:
public static bool CanGetObject(ApplicationContext appContext)
{
return Csla.Rules.BusinessRules.HasPermission(appContext, Csla.Rules.AuthorizationActions.GetObject, typeof(AddressAddressTypeList));
}
The method signatures match and ApplicationContext is valid. What could be happening to get the exception:
Object of type 'Csla.Rules.AddObjectAuthorizationRulesContext' cannot be converted to type 'Csla.ApplicationContext'.
Call Stack only shows what I've posted. Help! :-)
Beta Was this translation helpful? Give feedback.
All reactions