public string CreateNewUser(SignUpModel model) { if (IsNewUserValid(model)) { var salt = GenerateSequenceOfChars(20); // TODO: check facility name length var password = GeneratePassword(model.FacilityName); var user = new UserPurchase { Email = model.Email, PasswordSalt = salt, Password = HashPassword(password, salt), FacilityName = model.FacilityName, UserRegistrationDate = DateTime.Now, UserExpirationDate = DateTime.Now.AddMonths(6) }; _context.UserPurchases.Add(user); _context.SaveChanges(); return(password); } return(null); }
public string CreateNewUser(SignUpModel model) { if (IsNewUserValid(model)) { var salt = GenerateSequenceOfChars(20); // TODO: check facility name length var password = GeneratePassword(model.FacilityName); var user = new UserPurchase { Email = model.Email, PasswordSalt = salt, Password = HashPassword(password, salt), FacilityName = model.FacilityName, UserRegistrationDate = DateTime.Now, UserExpirationDate = DateTime.Now.AddMonths(6) }; _context.UserPurchases.Add(user); _context.SaveChanges(); return password; } return null; }
public ActionResult Index(SignUpModel model) { try { var password = userRepository.CreateNewUser(model); if (password != null) { return Content(string.Format("<html><head></head><body><h2>Succes</h2><p>Password is: {0}</p></body></html>", password)); } else { throw new Exception("Cannot create user"); } } catch (Exception e) { ModelState.AddModelError("", e.Message); return View(model); } }
private Boolean IsNewUserValid(SignUpModel model) { // TODO: implement return(true); }
private Boolean IsNewUserValid(SignUpModel model) { // TODO: implement return true; }