Example #1
0
        public bool Register(RegisterInputModel model)
        {
            if (model.IsValid())
                return false;

            var customer = Customer.CreateNew(model.Gender, model.UserName, model.FirstName, model.LastName, model.Email);
            customer.SetAvatar(model.Avatar);
            var hash = _hashingService.Hash(model.Password);
            customer.SetPasswordHash(hash);
            return _customerRepository.Add(customer);
        }
Example #2
0
        public ActionResult Register(RegisterInputModel model)
        {
            // Add customer and sign in
            var succeeded = _service.Register(model);
            if (succeeded)
            {
                var identity = IdentityHelpers.Create(model.UserName, model.Email, model.Gender);
                AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = true }, identity);
                return RedirectToAction("Index", "Home");
            }

            ModelState.AddModelError("failed", "Oh snap! Change a few things up and try again!");
            return View(model);
        }
Example #3
0
 public ActionResult Register()
 {
     var model = new RegisterInputModel();
     return View(model);
 }
Example #4
0
        public ActionResult AddDetailsPost(AddDetailsViewModel model)
        {
            // Create a user too if missing
            var customer = _service.GetCustomer(model.UserName);
            if (customer == null)
            {
                var register = new RegisterInputModel()
                {
                    UserName = model.UserName,
                    Email = model.Email,
                    FirstName = model.FirstName,
                    LastName = model.LastName,
                    Gender = model.Gender,
                    Avatar = model.Avatar
                };
                _service.Register(register);
            }

            var identity = IdentityHelpers.Create(model.UserName, model.Email, model.Gender, model.Avatar);
            AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = true }, identity);
            return RedirectToLocal(model.ReturnUrl);
        }