Ignore:
Timestamp:
08/20/24 16:13:49 (6 weeks ago)
Author:
ElenaMoskova <elena.moskova99@…>
Branches:
main
Children:
63bd770
Parents:
8f8226c
Message:

fix authorization

implement hiding menu items

File:
1 edited

Legend:

Unmodified
Added
Removed
  • PostgreSqlDotnetCore/Controllers/HomeController.cs

    r8f8226c r6782104  
    44using PostgreSqlDotnetCore.Models;
    55using System.Diagnostics;
     6using System.Web.Mvc;
    67
    78namespace PostgreSqlDotnetCore.Controllers
    89{
    910
    10     public class HomeController : Controller
     11    public class HomeController : BaseController
    1112    {
    1213        private ApplicationDbContext db = new ApplicationDbContext();
     
    1516        private readonly ILogger<HomeController> _logger;
    1617
    17         public HomeController(ILogger<HomeController> logger, UserManager<IdentityUser> userManager)
     18        public HomeController(ILogger<HomeController> logger, UserManager<IdentityUser> userManager) : base(userManager)
    1819        {
    1920            _logger = logger;
     
    5657                        db.SaveChanges();
    5758                    }
    58 
     59                    // set if is authenticated
     60                    ViewBag.isAuthenticated = await getCrrentUser();
    5961                }
    6062
     63            } else
     64            {
     65                ViewBag.isAuthenticated = null;
    6166            }
    6267            ViewBag.ShowTopBar = true;
     68
    6369            return View();
    6470        }
    6571
    66         public IActionResult Privacy()
     72        public async Task<IActionResult> PrivacyAsync()
    6773        {
     74
     75            // set if is authenticated
     76            ViewBag.isAuthenticated = await getCrrentUser();
    6877            return View();
    6978        }
    70         public IActionResult Contact()
     79        public async Task<IActionResult> ContactAsync()
    7180        {
     81            // set if is authenticated
     82            ViewBag.isAuthenticated = await getCrrentUser();
    7283            return View();
    7384        }
Note: See TracChangeset for help on using the changeset viewer.