permission handling
This commit is contained in:
@ -30,7 +30,7 @@ namespace Yavsc.Helpers
|
||||
{
|
||||
var userPosts = dbContext.BlogSpot.Include(
|
||||
b => b.Author
|
||||
).Where(x => ((x.AuthorId == posterId) && (x.Visible))).ToArray();
|
||||
).Where(x => ((x.AuthorId == posterId))).ToArray();
|
||||
return userPosts;
|
||||
}
|
||||
else
|
||||
@ -42,8 +42,7 @@ namespace Yavsc.Helpers
|
||||
return dbContext.BlogSpot.Include(
|
||||
b => b.Author
|
||||
).Include(p => p.ACL).Where(x => x.Author.Id == posterId &&
|
||||
(x.Visible &&
|
||||
(x.ACL.Count == 0 || x.ACL.Any(a => readerCirclesMemberships.Contains(a.CircleId)))));
|
||||
(x.ACL.Count == 0 || x.ACL.Any(a => readerCirclesMemberships.Contains(a.CircleId))));
|
||||
|
||||
|
||||
}
|
||||
|
@ -18,14 +18,14 @@ namespace Yavsc.Models.Blog
|
||||
{
|
||||
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Display(Name="Identifiant du post")]
|
||||
public long Id { get; set; }
|
||||
public long Id { get; set; }
|
||||
|
||||
[Display(Name="Identifiant de l'auteur")]
|
||||
[ForeignKey("Author")]
|
||||
public string AuthorId { get; set; }
|
||||
public string AuthorId { get; set; }
|
||||
|
||||
[Display(Name="Auteur")]
|
||||
public virtual ApplicationUser Author { set; get; }
|
||||
public virtual ApplicationUser Author { set; get; }
|
||||
|
||||
|
||||
[Display(Name="Date de création")]
|
||||
@ -35,7 +35,7 @@ namespace Yavsc.Models.Blog
|
||||
}
|
||||
|
||||
[Display(Name="Créateur")]
|
||||
public string UserCreated
|
||||
public string UserCreated
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
@ -47,7 +47,7 @@ namespace Yavsc.Models.Blog
|
||||
}
|
||||
|
||||
[Display(Name="Utilisateur ayant modifé le dernier")]
|
||||
public string UserModified
|
||||
public string UserModified
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
@ -68,7 +68,7 @@ namespace Yavsc.Models.Blog
|
||||
if (existent==null) Tags.Add(new BlogTag { PostId = Id, Tag = tag } );
|
||||
}
|
||||
|
||||
public void Detag(Tag tag)
|
||||
public void DeTag(Tag tag)
|
||||
{
|
||||
var existent = Tags.SingleOrDefault(t => (( t.TagId == tag.Id) && t.PostId == Id));
|
||||
if (existent!=null) Tags.Remove(existent);
|
||||
@ -80,10 +80,10 @@ namespace Yavsc.Models.Blog
|
||||
}
|
||||
|
||||
[InverseProperty("Post")]
|
||||
public virtual List<BlogTag> Tags { get; set; }
|
||||
public virtual List<BlogTag> Tags { get; set; }
|
||||
|
||||
[InverseProperty("Post")]
|
||||
public virtual List<Comment> Comments { get; set; }
|
||||
public virtual List<Comment> Comments { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public string OwnerId => AuthorId;
|
||||
|
12
src/Yavsc.Server/ViewModels/Auth/DeletePermission.cs
Normal file
12
src/Yavsc.Server/ViewModels/Auth/DeletePermission.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth
|
||||
{
|
||||
public class DeletePermission: IAuthorizationRequirement
|
||||
{
|
||||
public DeletePermission()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
12
src/Yavsc.Server/ViewModels/Auth/EditPermission.cs
Normal file
12
src/Yavsc.Server/ViewModels/Auth/EditPermission.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth
|
||||
{
|
||||
public class EditPermission : IAuthorizationRequirement
|
||||
{
|
||||
public EditPermission()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth
|
||||
{
|
||||
public class EditPermission : IAuthorizationRequirement
|
||||
{
|
||||
public EditPermission()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class ReadPermission: IAuthorizationRequirement
|
||||
{
|
||||
public ReadPermission()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class DeletePermission: IAuthorizationRequirement
|
||||
{
|
||||
public DeletePermission()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -2,10 +2,11 @@ using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth
|
||||
{
|
||||
public class ViewRequirement : IAuthorizationRequirement
|
||||
public class ReadPermission: IAuthorizationRequirement
|
||||
{
|
||||
public ViewRequirement()
|
||||
public ReadPermission()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
src/Yavsc.Server/ViewModels/BlogSpot/BlogPostEdit.cs
Normal file
11
src/Yavsc.Server/ViewModels/BlogSpot/BlogPostEdit.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Yavsc.ViewModels.Blog;
|
||||
|
||||
public class BlogPostEditViewModel : BlogPostInputViewModel
|
||||
{
|
||||
|
||||
[Required]
|
||||
|
||||
public required long Id { get; set; }
|
||||
}
|
@ -8,19 +8,18 @@ namespace Yavsc.ViewModels.Blog
|
||||
public class BlogPostInputViewModel
|
||||
{
|
||||
[StringLength(1024)]
|
||||
public string? Photo { get; set; }
|
||||
public string? Photo { get; set; }
|
||||
|
||||
[StringLength(1024)]
|
||||
public required string Title { get; set; }
|
||||
public string Title { get; set; }
|
||||
|
||||
[StringLength(56224)]
|
||||
public required string Content { get; set; }
|
||||
|
||||
public bool Visible { get; set; }
|
||||
public string Content { get; set; }
|
||||
|
||||
[InverseProperty("Target")]
|
||||
[Display(Name="Liste de contrôle d'accès")]
|
||||
public virtual List<CircleAuthorizationToBlogPost>? ACL { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yavsc.ViewModels.BlogSpot
|
||||
{
|
||||
public class NewPost
|
||||
{
|
||||
[Required]
|
||||
public string Title{ get; set; }
|
||||
|
||||
[Required]
|
||||
public string Content { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user