Beispiel #1
0
        public async Task <IActionResult> Authorization(EnterViewModel loginViewModel)
        {
            _logger.LogInformation(loginViewModel.Login);
            _logger.LogInformation(loginViewModel.Password);
            People human = _peopleRepository.CheckData(loginViewModel.Login, Encryption.Encryption.GetHash(loginViewModel.Password));

            if (human == null)
            {
                ModelState.AddModelError("", "Неправильный логин или пароль!");
                _peopleRepository.ClearCache();
            }

            if (ModelState.IsValid)
            {
                await Authenticate(human);

                if (human.RoleId == 3)
                {
                    return(RedirectToAction("Phone", "Market"));
                }
                return(RedirectToAction("Warehouse", "Staff"));
            }

            return(View(loginViewModel));
        }