Example #1
0
 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;
 }
Example #2
0
        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);
        }
Example #3
0
 public ActionResult SignIn(String returnUrl)
 {
     var model = new LoginInputModel {ReturnUrl = returnUrl, RememberMe = true};
     return View(model);
 }