public ActionResult Register(RegisterViewModel model, string returnUrl) { if (ModelState.IsValid) { User userByEmail = repo.User(email: model.RegisterEmail); string randomToken = account.GetUniqueToken(textBuilder.GetRandomString(), repo); string action = Url.AbsoluteAction("ConfirmEmail", "Account", new { token = randomToken }, repoConfig); if (account.SetUserTemp(repo, model, randomToken) != null && account.SendInviteUserEmail(model, action)) { this.SetMessage(InfoMessageType.Success, Resources.SentLink); } else { this.SetMessage(InfoMessageType.Danger, Resources.SentLinkProblem); } } return(Redirect(returnUrl ?? Url.Action("Index", "Home"))); }
public bool RegisterAndLogByEmail(string email, int source, Controller controller) { if (!IsUserRegistered(email)) { string pass = textBuilder.GetRandomString(); string randomToken = GetUniqueToken(textBuilder.GetRandomString(), repoUser); SetUserTemp(repoUser, new RegisterViewModel { RegisterEmail = email, RegisterPassword = pass }, randomToken); User user = repoUser.TransferUserTemp(randomToken, source); if (user == null || !SetUserLogged(email, user.Password, repoUser, controller)) { return(false); } } else { SetUserLoggedAbsolutely(email, repoUser, controller); } return(true); }