Ejemplo n.º 1
0
        public virtual ActionResult CreateUser(viewModels.RegisterViewModel model)
        {
            MembershipUser         user;
            MembershipCreateStatus status;

            user = membershipService.CreateUser(model.UserName, model.Password, model.Email, model.SecretQuestion, model.SecretAnswer, model.Approve, out status);
            JsonResponse response = new JsonResponse();

            if (user == null)
            {
                response.Success = false;
                response.Message = status.ToString();
                if (status == MembershipCreateStatus.InvalidPassword)
                {
                    ModelState.AddModelError("", "Password must be at least 6 characters.");
                }
                else if (status == MembershipCreateStatus.InvalidEmail)
                {
                    ModelState.AddModelError("", "The provided email is wrong.");
                }
                return(RedirectToAction("CreateUser"));
            }

            return(routeHelpers.Actions.GrantRolesToUser(user.UserName));
        }
Ejemplo n.º 2
0
        public virtual ActionResult Register()
        {
            var model = new viewModels.RegisterViewModel()
            {
                RequireSecretQuestionAndAnswer = membershipService.RequiresQuestionAndAnswer
            };

            return(ContextDependentView(model));
        }
Ejemplo n.º 3
0
        public virtual ActionResult CreateUser()
        {
            var model = new viewModels.RegisterViewModel()
            {
                RequireSecretQuestionAndAnswer = membershipService.RequiresQuestionAndAnswer
            };

            return(View(model));
        }
Ejemplo n.º 4
0
        public virtual ActionResult CreateUser(viewModels.RegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "You are missing required fields.");
                return(RedirectToAction("CreateUser"));
            }
            MembershipUser         user;
            MembershipCreateStatus status;

            user = membershipService.CreateUser(model.UserName, model.Password, model.Email, model.SecretQuestion, model.SecretAnswer, model.Approve, out status);

            return(routeHelpers.Actions.GrantRolesToUser(user.UserName));
        }
Ejemplo n.º 5
0
        public virtual ActionResult Register(viewModels.RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                membershipService.CreateUser(model.UserName, model.Password, model.Email, model.SecretQuestion, model.SecretAnswer, true, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    formsAuthenticationService.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            return(RedirectToAction("Register"));
        }
Ejemplo n.º 6
0
        public JsonResult JsonRegister(viewModels.RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                membershipService.CreateUser(model.UserName, model.Password, model.Email, model.SecretQuestion, model.SecretAnswer, true, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    formsAuthenticationService.SetAuthCookie(model.UserName, false);

                    return(Json(new { success = true }));
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            return(Json(new { errors = GetErrorsFromModelState() }));
        }
Ejemplo n.º 7
0
 public virtual ActionResult Register()
 {
     var model = new viewModels.RegisterViewModel()
     {
         RequireSecretQuestionAndAnswer = membershipService.RequiresQuestionAndAnswer
     };
     return ContextDependentView(model);
 }
Ejemplo n.º 8
0
 public virtual ActionResult CreateUser()
 {
     var model = new viewModels.RegisterViewModel()
     {
         RequireSecretQuestionAndAnswer = membershipService.RequiresQuestionAndAnswer
     };
     return View(model);
 }