WIP
This commit is contained in:
parent
96dcf5c4f4
commit
0d8fd0606f
60 changed files with 874 additions and 209 deletions
21
Yavsc/ViewModels/Auth/Handlers/CommandViewHandler.cs
Normal file
21
Yavsc/ViewModels/Auth/Handlers/CommandViewHandler.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth.Handlers
|
||||
{
|
||||
using Models.Booking;
|
||||
public class CommandViewHandler : AuthorizationHandler<ViewRequirement, BookQuery>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, ViewRequirement requirement, BookQuery 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue