public Customer ValidateAndReturn(LoginInputModel model) { var customer = _customerRepository.FindById(model.UserName); if (customer != null) { if (model.Password.IsNullOrEmpty()) return customer; if (_hashingService.Validate(model.Password, customer.PasswordHash)) return customer; } return null; }
public ActionResult SignIn(LoginInputModel model, String returnUrl) { // Validate credentials var customer = _service.ValidateAndReturn(model); if (customer != null) { var identity = IdentityHelpers.Create(customer.CustomerId, customer.Email, customer.Gender, customer.Avatar); AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = true }, identity); return RedirectToLocal(returnUrl); } ModelState.AddModelError("failed", "Oh snap! Change a few things up and try again!"); return View(model); }
public ActionResult SignIn(String returnUrl) { var model = new LoginInputModel {ReturnUrl = returnUrl, RememberMe = true}; return View(model); }