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/PetsController.cs

    r8f8226c r6782104  
    1919            // check for permission
    2020            UsersClass customerClass = await getCrrentUser();
     21
     22            // set if is authenticated
     23            ViewBag.isAuthenticated = customerClass;
    2124            if (customerClass == null)
    2225            {
     
    6265        //}
    6366
    64         public ActionResult Create()
     67        public async Task<ActionResult> CreateAsync()
    6568        {
    66            
     69
     70            // check for permission
     71            UsersClass customerClass = await getCrrentUser();
     72            // set if is authenticated
     73            ViewBag.isAuthenticated = customerClass;
    6774            return View();
    6875        }
     
    7885            if (!isAuthenticated)
    7986            {
     87                // set if is authenticated
     88                ViewBag.isAuthenticated = null;
    8089                return RedirectToAction("AccessDenied", "Error");
    8190            }
     91            ViewBag.isAuthenticated = new UsersClass();
     92
    8293            if (ModelState.IsValid)
    8394            {
    84                // peClass.dateofbirthday = DateTime.SpecifyKind(peClass.dateofbirthday, DateTimeKind.Utc);
     95                // set if is authenticated
     96                ViewBag.isAuthenticated = new UsersClass();
     97                // peClass.dateofbirthday = DateTime.SpecifyKind(peClass.dateofbirthday, DateTimeKind.Utc);
    8598                var user = await _userManager.GetUserAsync(User);
    8699                var customerClass = db.CustomerObj.SingleOrDefault(x => x.email == user.Email);
     
    121134            if (!isAuthenticated)
    122135            {
     136                // set if is authenticated
     137                ViewBag.isAuthenticated = null;
    123138                return RedirectToAction("AccessDenied", "Error");
    124139            }
     140
     141            // set if is authenticated
     142            ViewBag.isAuthenticated = new UsersClass();
     143           
    125144             
    126145            if (ModelState.IsValid)
Note: See TracChangeset for help on using the changeset viewer.