feat/postit-acl-members #41
3 changed files with 21 additions and 6 deletions
A Circle must pre-exist before beeing used by an authorization
commit
8f91cbed02
10
src/Yavsc.Abstract/Blogspot/PostAccessControlRulePayload.cs
Normal file
10
src/Yavsc.Abstract/Blogspot/PostAccessControlRulePayload.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
using Yavsc.Abstract.Identity.Security;
|
||||
|
||||
namespace Yavsc.Abstract.BlogSpot;
|
||||
|
||||
public class PostAccessControlRulePayload : ICircleAuthorization
|
||||
{
|
||||
public long CircleId { get; set; }
|
||||
public long BlogPostId { get; set; }
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Security.Claims;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Abstract.BlogSpot;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Access;
|
||||
using Yavsc.Server.Helpers;
|
||||
|
|
@ -103,7 +104,8 @@ namespace Yavsc.Blogs.Controllers
|
|||
}
|
||||
// POST: api/BlogAclApi
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostCircleAuthorizationToBlogPost([FromBody] CircleAuthorizationToBlogPost circleAuthorizationToBlogPost)
|
||||
public async Task<IActionResult> PostCircleAuthorizationToBlogPost(
|
||||
[FromBody] PostAccessControlRulePayload circleAuthorizationToBlogPost)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
|
|
@ -113,7 +115,12 @@ namespace Yavsc.Blogs.Controllers
|
|||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
_context.CircleAuthorizationToBlogPost.Add(circleAuthorizationToBlogPost);
|
||||
CircleAuthorizationToBlogPost entity = new CircleAuthorizationToBlogPost
|
||||
{
|
||||
BlogPostId = circleAuthorizationToBlogPost.BlogPostId,
|
||||
CircleId = circleAuthorizationToBlogPost.CircleId
|
||||
};
|
||||
_context.CircleAuthorizationToBlogPost.Add(entity);
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
|
|
|
|||
|
|
@ -5,12 +5,10 @@ namespace Yavsc.Models.Access
|
|||
using Newtonsoft.Json;
|
||||
using Blog;
|
||||
using Yavsc.Abstract.Identity.Security;
|
||||
using Yavsc.Abstract.BlogSpot;
|
||||
|
||||
public class CircleAuthorizationToBlogPost : ICircleAuthorization
|
||||
public class CircleAuthorizationToBlogPost : PostAccessControlRulePayload
|
||||
{
|
||||
public long CircleId { get; set; }
|
||||
public long BlogPostId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey("BlogPostId")]
|
||||
public virtual BlogPost Target { get; set; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue