WIP
This commit is contained in:
parent
96dcf5c4f4
commit
0d8fd0606f
60 changed files with 874 additions and 209 deletions
19
Yavsc/ViewModels/Auth/Handlers/BlogEditHandler.cs
Normal file
19
Yavsc/ViewModels/Auth/Handlers/BlogEditHandler.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using Microsoft.AspNet.Authorization;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth.Handlers
|
||||
{
|
||||
using System.Security.Claims;
|
||||
using Models;
|
||||
public class BlogEditHandler : AuthorizationHandler<EditRequirement, Blog>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, EditRequirement requirement, Blog resource)
|
||||
{
|
||||
if (context.User.IsInRole(Constants.BlogModeratorGroupName))
|
||||
context.Succeed(requirement);
|
||||
else if (context.User.Identity.IsAuthenticated)
|
||||
if (resource.AuthorId == context.User.GetUserId())
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue