Example #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));
        }
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 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));
        }