Esempio n. 1
0
        public console.Models.tbl_User FindUser(DreamTech.Models.LoginViewModel model)
        {
            var repo = new Repos.UserRepo();
            var user = repo.GetLoginDetails(model.Email, model.Password);

            if (user == null)
            {
                return(null);
            }
            else
            {
                return(user);
            }
        }
Esempio n. 2
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            var repo = new Repos.UserRepo();
            var user = repo.GetLoginDetails(model.Email, model.Password);

            if (user == null)
            {
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
            else
            {
                System.Web.Security.FormsAuthentication.SetAuthCookie(model.Email, false);
                return(RedirectToLocal(returnUrl));
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            //var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
            //switch (result)
            //{
            //    case SignInStatus.Success:
            //        return RedirectToLocal(returnUrl);
            //    case SignInStatus.LockedOut:
            //        return View("Lockout");
            //    case SignInStatus.RequiresVerification:
            //        return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
            //    case SignInStatus.Failure:
            //    default:
            //        ModelState.AddModelError("", "Invalid login attempt.");
            //        return View(model);
            //}
        }