Example #1
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid && ValidateNewUser(model))
            {
                // Attempt to register the user
                var createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    return RedirectToAction("LogOn", "Account");
                }
                ModelState.AddModelError("", createStatus.ErrorCodeToString());
            }

            var userEntity = GetNewUserIDByTicket(model.NewUserTicket);
            if (userEntity != null)
            {
                model.UserDisplayName = userEntity.UserDisplayName;
            }
            model.Title = SettingsRepository.BlogName;
            return View(model);
        }
Example #2
0
        private bool ValidateNewUser(RegisterModel model)
        {
            var userEntity = GetNewUserIDByTicket(model.NewUserTicket);
            if (userEntity != null)
            {
                if (userEntity.UserEmailAddress == model.Email && userEntity.UserID == model.UserID)
                    return true;
            }

            ModelState.AddModelError("", "Unable to validate the information you entered");
            return false;
        }
Example #3
0
        // **************************************
        // URL: /Account/Register
        // **************************************

        public ActionResult Register(string newUserTicket)
        {
            var userEntity = GetNewUserIDByTicket(newUserTicket);
            if (userEntity == null || Request.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }

            var registerModel = new RegisterModel
            {
                Title = SettingsRepository.BlogName,
                NewUserTicket = newUserTicket,
                UserID = userEntity.UserID,
                UserDisplayName = userEntity.UserDisplayName
            };
            return View(registerModel);
        }