public ActionResult Join(AccountSignupVM model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var accountExists = accountManager.DoesAccountExist(model.Email);
                    if (!accountExists)
                    {
                        var newUser = new UserAccountDto { EmailAddress = model.Email, Name = model.Name, Password = model.Password };
                        var userSession = accountManager.CreateUserAccount(newUser);

                        if (userSession.UserId > 0)
                        {
                            SetUserIDToSession(userSession);
                        }

                        if (!String.IsNullOrEmpty(model.ReturnUrl))
                            return RedirectToAction("joinmyteam", "users", new { id = model.ReturnUrl });

                        return RedirectToAction("accountcreated");

                    }
                    else
                    {
                        ModelState.AddModelError("", "Account already exists with this email address");
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
            return View(model);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Join(AccountSignupVM model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var accountExists = await _userAccountManager.GetUser(model.Email);

                    if (accountExists == null)
                    {
                        var newUser = new UserAccountDto
                        {
                            EmailAddress = model.Email,
                            Name         = model.Name,
                            Password     = model.Password
                        };
                        var userSession = await _userAccountManager.CreateAccount(newUser);

                        if (userSession.UserId > 0)
                        {
                            _userSessionHelper.SetUserIDToSession(userSession);
                        }

                        if (!String.IsNullOrEmpty(model.ReturnUrl))
                        {
                            return(RedirectToAction(nameof(UsersController.JoinMyTeam), "users", new { id = model.ReturnUrl }));
                        }

                        return(RedirectToAction(nameof(AccountController.AccountCreated)));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Account already exists with this email address");
                    }
                }
            }
            catch (Exception ex)
            {
                tc.TrackException(ex);
                ModelState.AddModelError("", "Error processing your request!");
            }
            return(View(model));
        }
        public async Task <ActionResult> Join(AccountSignupVM model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var accountExists = await userAccountManager.GetUser(model.Email);

                    if (accountExists == null)
                    {
                        var newUser = new UserAccountDto
                        {
                            EmailAddress = model.Email,
                            Name         = model.Name,
                            Password     = model.Password
                        };
                        var userSession = await userAccountManager.CreateAccount(newUser);

                        if (userSession.UserId > 0)
                        {
                            userSessionHelper.SetUserIDToSession(userSession);
                        }

                        if (!String.IsNullOrEmpty(model.ReturnUrl))
                        {
                            return(RedirectToAction("joinmyteam", "users", new { id = model.ReturnUrl }));
                        }

                        return(RedirectToAction("accountcreated"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Account already exists with this email address");
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(View(model));
        }