Files
yavsc/Yavsc/ViewModels/Auth/Handlers/CommandViewHandler.cs
2017-02-27 19:28:32 +01:00

21 lines
764 B
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Security.Claims;
using Microsoft.AspNet.Authorization;
namespace Yavsc.ViewModels.Auth.Handlers
{
using Models.Workflow;
public class CommandViewHandler : AuthorizationHandler<ViewRequirement, RdvQuery>
{
protected override void Handle(AuthorizationContext context, ViewRequirement requirement, RdvQuery resource)
{
if (context.User.IsInRole("FrontOffice"))
context.Succeed(requirement);
else if (context.User.Identity.IsAuthenticated)
if (resource.ClientId == context.User.GetUserId())
context.Succeed(requirement);
else if (resource.PerformerId == context.User.GetUserId())
context.Succeed(requirement);
}
}
}