From b3dc929b5e550374ecf3085c72d769157e99c016 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 6 Feb 2017 17:51:49 +0100 Subject: [PATCH] use authorization service to view post --- Yavsc/Controllers/BlogspotController.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Yavsc/Controllers/BlogspotController.cs b/Yavsc/Controllers/BlogspotController.cs index 622afde1..7631d66f 100644 --- a/Yavsc/Controllers/BlogspotController.cs +++ b/Yavsc/Controllers/BlogspotController.cs @@ -11,6 +11,7 @@ using Microsoft.Extensions.OptionsModel; using Yavsc.Models; using Yavsc.ViewModels.Auth; using Microsoft.AspNet.Mvc.Rendering; +using Yavsc.ViewModels; // For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 @@ -96,7 +97,7 @@ namespace Yavsc.Controllers } // GET: Blog/Details/5 [AllowAnonymous] - public IActionResult Details(long? id) + public async Task Details(long? id) { if (id == null) { @@ -110,7 +111,10 @@ namespace Yavsc.Controllers { return HttpNotFound(); } - + if (!await _authorizationService.AuthorizeAsync(User, blog, new ViewRequirement())) + { + return new ChallengeResult(); + } return View(blog); }