CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
HasPermissionHandler.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="CslaPermissionsHandler.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Authorization handler for CSLA permissions</summary>
7//-----------------------------------------------------------------------
8using System.Threading.Tasks;
9using Microsoft.AspNetCore.Authorization;
10
11namespace Csla.Blazor
12{
16 public class CslaPermissionsHandler : AuthorizationHandler<CslaPermissionRequirement>
17 {
18 private ApplicationContext ApplicationContext { get; set; }
19
24 public CslaPermissionsHandler(ApplicationContext applicationContext)
25 {
26 ApplicationContext = applicationContext;
27 }
28
35 protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, CslaPermissionRequirement requirement)
36 {
37 if (Rules.BusinessRules.HasPermission(ApplicationContext, requirement.Action, requirement.ObjectType))
38 context.Succeed(requirement);
39 else
40 context.Fail();
41 return Task.CompletedTask;
42 }
43 }
44}
Provides consistent context information between the client and server DataPortal objects.
Rules.AuthorizationActions Action
Gets or sets the authorization action
Type ObjectType
Gets or sets the business object type
Authorization handler for CSLA permissions.
override Task HandleRequirementAsync(AuthorizationHandlerContext context, CslaPermissionRequirement requirement)
Handle requirements
CslaPermissionsHandler(ApplicationContext applicationContext)
Creates an instance of the type.