main
Last change
on this file since 99d0ecc 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
|
Rev | Line | |
---|
[2aea0fd] | 1 | namespace PostgreSqlDotnetCore.Controllers
|
---|
| 2 | {
|
---|
| 3 | using Microsoft.AspNetCore.Http;
|
---|
[6782104] | 4 | using Microsoft.AspNetCore.Identity;
|
---|
[2aea0fd] | 5 | using Microsoft.AspNetCore.Mvc;
|
---|
[118e414] | 6 | using PostgreSqlDotnetCore.Models;
|
---|
[6782104] | 7 | using System.Threading.Tasks;
|
---|
[2aea0fd] | 8 |
|
---|
[6782104] | 9 | public class ErrorController : BaseController
|
---|
[2aea0fd] | 10 | {
|
---|
[6782104] | 11 | public ErrorController(UserManager<IdentityUser> userManager) : base(userManager)
|
---|
| 12 | {
|
---|
| 13 |
|
---|
| 14 | }
|
---|
[2aea0fd] | 15 | // GET: ErrorController
|
---|
[6782104] | 16 | public async Task<IActionResult> AccessDeniedAsync()
|
---|
[2aea0fd] | 17 | {
|
---|
[6782104] | 18 | // set if is authenticated
|
---|
| 19 | ViewBag.isAuthenticated = await getCrrentUser();
|
---|
[118e414] | 20 | // no access for standard user
|
---|
| 21 | ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
|
---|
| 22 |
|
---|
[2aea0fd] | 23 | return View();
|
---|
| 24 | }
|
---|
| 25 | // GET: ErrorController
|
---|
[6782104] | 26 | public async Task<IActionResult> NotExistAsync()
|
---|
[2aea0fd] | 27 | {
|
---|
[6782104] | 28 | // set if is authenticated
|
---|
| 29 | ViewBag.isAuthenticated = await getCrrentUser();
|
---|
[118e414] | 30 | // no access for standard user
|
---|
| 31 | ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
|
---|
| 32 |
|
---|
[2aea0fd] | 33 | return View();
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.