source: PostgreSqlDotnetCore/Controllers/ErrorController.cs@ 118e414

main
Last change on this file since 118e414 was 118e414, checked in by ElenaMoskova <elena.moskova99@…>, 3 months ago

fix access

implement multiple access pages with different roles
optimize present three structure of BlogPost and Answer

  • Property mode set to 100644
File size: 1.3 KB
Line 
1namespace PostgreSqlDotnetCore.Controllers
2{
3 using Microsoft.AspNetCore.Http;
4 using Microsoft.AspNetCore.Identity;
5 using Microsoft.AspNetCore.Mvc;
6 using PostgreSqlDotnetCore.Models;
7 using System.Threading.Tasks;
8
9 public class ErrorController : BaseController
10 {
11 public ErrorController(UserManager<IdentityUser> userManager) : base(userManager)
12 {
13
14 }
15 // GET: ErrorController
16 public async Task<IActionResult> AccessDeniedAsync()
17 {
18 // set if is authenticated
19 ViewBag.isAuthenticated = await getCrrentUser();
20 // no access for standard user
21 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
22
23 return View();
24 }
25 // GET: ErrorController
26 public async Task<IActionResult> NotExistAsync()
27 {
28 // set if is authenticated
29 ViewBag.isAuthenticated = await getCrrentUser();
30 // no access for standard user
31 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
32
33 return View();
34 }
35
36 }
37}
Note: See TracBrowser for help on using the repository browser.