Ignore:
Timestamp:
08/20/24 23:14:03 (6 weeks ago)
Author:
ElenaMoskova <elena.moskova99@…>
Branches:
main
Children:
57fc402
Parents:
63bd770
Message:

Аccess permission

File:
1 edited

Legend:

Unmodified
Added
Removed
  • PostgreSqlDotnetCore/Controllers/BlogController.cs

    r63bd770 rd6040ef  
    1111    {
    1212        public BlogController(UserManager<IdentityUser> userManager) : base(userManager)
    13         {
     13
     14        {
     15           
    1416        }
    1517
    1618        // GET: Customer
    17         public async Task<ActionResult> IndexAsync()
    18         {
    19             // check for permission
     19        /* public async Task<ActionResult> IndexAsync()
     20         {
     21             // check for permission
     22             bool isAuthenticated = User.Identity.IsAuthenticated;
     23             if (!isAuthenticated)
     24             {
     25                 return RedirectToAction("AccessDenied", "Error");
     26             }
     27             //return View(Enumerable.Empty<UsersClass>());
     28             return View(db.BlogPostControllerObj.ToList());
     29         }
     30        */
     31
     32        public async Task<ActionResult> Index()
     33        {
     34            // Проверка за автентикација
    2035            bool isAuthenticated = User.Identity.IsAuthenticated;
     36
    2137            if (!isAuthenticated)
    2238            {
    2339                return RedirectToAction("AccessDenied", "Error");
    2440            }
    25             //return View(Enumerable.Empty<UsersClass>());
    26             return View(db.BlogPostControllerObj.ToList());
    27         }
    28 
     41
     42            // Список на блог постови
     43            var blogPosts = await db.BlogPostControllerObj.ToListAsync();
     44
     45            // Предавање на ViewBag за проверка на автентикација
     46            ViewBag.isAuthenticated = isAuthenticated;
     47
     48            return View(blogPosts);
     49        }
    2950        // GET: Customer/Details/5
    3051        public async Task<ActionResult> DetailsAsync(int? id)
Note: See TracChangeset for help on using the changeset viewer.