Exemplo n.º 1
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));
        }
Exemplo n.º 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));
        }