Exemple #1
0
        public async Task <ActionResult> LockOut(LockOutRequest request)
        {
            User user = await userManager.Users.Include(u => u.LockRecord).Where(u => u.Id == request.Id).FirstOrDefaultAsync();

            IList <string> roles = await userManager.GetRolesAsync(await userManager.FindByIdAsync(request.Id.ToString()));

            if (roles.Any(r => r == "admin"))
            {
                return(Forbid());
            }
            User admin = await userManager.FindByEmailAsync(User.Identity.Name);

            logger.LogInformation($"Customers/LockOut: User {user.Email} has been blocked by admin {admin.Email}");
            return(Ok(new { lockoutEnd = await lockService.LockOut(user, request.Reason, request.Minutes, admin.Id) }));
        }