From 5e5dee0c0c3c99433ccb1a1cda6133fbc92f22f7 Mon Sep 17 00:00:00 2001 From: Mia Winter Date: Thu, 18 Jan 2024 22:00:54 +0100 Subject: [PATCH] Changed Drafts to allow admins access to all draft articles --- Wave/Components/Pages/Drafts.razor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Wave/Components/Pages/Drafts.razor b/Wave/Components/Pages/Drafts.razor index d595db7..c99ea31 100644 --- a/Wave/Components/Pages/Drafts.razor +++ b/Wave/Components/Pages/Drafts.razor @@ -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
() .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()); }