Exemplo n.º 1
0
        public async Task BanUserByUsername(BanInputModel inputModel)
        {
            await this.CheckIfUserExists(inputModel.Username);

            ApplicationUser user = this.context.Users.SingleOrDefault(u => u.UserName == inputModel.Username);

            var lockoutResult = await this.userManager.SetLockoutEndDateAsync(user, inputModel.BanUntil);

            if (lockoutResult.Succeeded)
            {
                this.tempDataDictionaryFactory
                .GetTempData(this.httpContext.HttpContext)
                .Add("Alert", $"You banned {user.UserName} until {inputModel.BanUntil}.");
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Ban(BanInputModel inputModel)
        {
            await this.userService.BanUserByUsername(inputModel);

            return(this.RedirectToAction("Ban"));
        }