Changed Drafts to allow admins access to all draft articles

This commit is contained in:
Mia Rose Winter 2024-01-18 22:00:54 +01:00
parent 885a0c5a0e
commit 5e5dee0c0c
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E

View file

@ -27,10 +27,11 @@
await using var context = await ContextFactory.CreateDbContextAsync();
string userId = UserManager.GetUserId(HttpContext.User)!;
bool admin = HttpContext.User.IsInRole("Admin");
Articles.AddRange(await
context.Set<Article>()
.Include(a => a.Author)
.Where(a => a.Status == ArticleStatus.Draft && a.Author.Id == userId)
.Where(a => a.Status == ArticleStatus.Draft && (admin || a.Author.Id == userId))
.OrderByDescending(a => a.PublishDate)
.ToListAsync());
}