public ActionResult Registration(RegisterModel model)
        {
            string Photo = "UploadedFiles/BbYcwnFaN3o.jpg";
            if (ModelState.IsValid)
            {
                UserEntity user = CustomMembershipProvider.CreateUser(model.Login, model.Email, model.Password, Photo);
                if (null != user)
                {
                    var setCockie = DependencyResolver.Current.GetService<ICustomAuthenticationService>();
                    setCockie.SignIn(new Identity(user), false);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", "Registration error, this login or email already exist");
                }
            }

            return View(model);
        }
Пример #2
0
        public ActionResult Index(RegisterModel model, string role = "")
        {
            ViewBag.roles = RoleKeys.names;

            ActionResult result = View(model);

            if (ModelState.IsValid)
            {
                if (null != CustomMembershipProvider.CreateUser(model.Login, model.Email, model.Password))
                {
                    if (role != String.Empty) CustomRoleProvider.AddUsersToRoles(new string[] { model.Login }, new string[] { role });
                    result = RedirectToAction("Index", new { message = "Account " + model.Login + " create" });
                }
                else
                {
                    ModelState.AddModelError("", "Registration error, this login or email already exist");
                }
            }

            return result;
        }
Пример #3
0
        public ActionResult Register(RegisterModel model)
        {
            ActionResult result = View(model);

            if (ModelState.IsValid)
            {
                UserEntity user = CustomMembershipProvider.CreateUser(model.Login, model.Email, model.Password);
                if (null != user)
                {
                    CustomRoleProvider.AddUsersToRoles(new string[] { model.Login }, new string[] { RoleKeys.roleUser });
                    var setCockie = DependencyResolver.Current.GetService<ICustomAuthenticationService>();
                    setCockie.SignIn(new Identity(user), false);
                    result = RedirectToAction("Index", "Home", new { area = RoleKeys.roleUser });
                }
                else
                {
                    ModelState.AddModelError("", "Registration error, this login or email already exist");
                }
            }

            return result;
        }
Пример #4
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

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

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Пример #5
0
 public ActionResult Index(RegisterModel model, string id)
 {
     return View();
 }