Changed Drafts to allow admins access to all draft articles
This commit is contained in:
parent
885a0c5a0e
commit
5e5dee0c0c
|
@ -27,10 +27,11 @@
|
||||||
await using var context = await ContextFactory.CreateDbContextAsync();
|
await using var context = await ContextFactory.CreateDbContextAsync();
|
||||||
string userId = UserManager.GetUserId(HttpContext.User)!;
|
string userId = UserManager.GetUserId(HttpContext.User)!;
|
||||||
|
|
||||||
|
bool admin = HttpContext.User.IsInRole("Admin");
|
||||||
Articles.AddRange(await
|
Articles.AddRange(await
|
||||||
context.Set<Article>()
|
context.Set<Article>()
|
||||||
.Include(a => a.Author)
|
.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)
|
.OrderByDescending(a => a.PublishDate)
|
||||||
.ToListAsync());
|
.ToListAsync());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue