Esempio n. 1
0
        public async Task <IActionResult> Index(LoginViewModel viewModel)
        {
            viewModel.Login = await LMgr.GetLoginAsync(viewModel.Login.UserID);

            if (viewModel.Login?.IsLocked == true)
            {
                await LMgr.UpdateLockAsync(viewModel.Login);
            }

            viewModel.Validate(ModelState);
            if (!ModelState.IsValid)
            {
                if (viewModel.AuthFailed)
                {
                    await LMgr.IncrementAttemptsAsync(viewModel.Login);
                }
                return(View(viewModel));
            }

            await LMgr.ClearAttemptsAsync(viewModel.Login);

            CustomerSessionKey.SetToSession(viewModel.Login.Customer, HttpContext.Session);

            return(RedirectToAction("Index", "Customer"));
        }
Esempio n. 2
0
        public async Task <IActionResult> Index(LoginViewModel viewModel)
        {
            viewModel.Login = await LMgr.GetLoginAsync(viewModel.Login.UserID);

            viewModel.Validate(ModelState);
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            CustomerSessionKey.SetToSession(viewModel.Login.Customer, HttpContext.Session);

            return(RedirectToAction("Index", "Customer"));
        }