email verification, asp.net

Miguel Boavida
Miguel Boavida used Ask the Experts™
on
the code is from a microsoft tutorial called wingtip toys in asp.net, that code creates a user everytime the user clicks the button what i want is to when someone clicks on the button the program doesnt create the user, only creats if the user confirms his email. thanks

protected void CreateUser_Click(object sender, EventArgs e)
    {
        var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
        var signInManager = Context.GetOwinContext().Get<ApplicationSignInManager>();
        var user = new ApplicationUser() { UserName = Email.Text, Email = Email.Text };
        IdentityResult result = manager.Create(user, Password.Text);
        if (result.Succeeded)
        {
            // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
            //string code = manager.GenerateEmailConfirmationToken(user.Id);
            //string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request);
            //manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");

            signInManager.SignIn(user, isPersistent: false, rememberBrowser: false);

            using (WingtipToys.Logic.ShoppingCartActions usersShoppingCart = new WingtipToys.Logic.ShoppingCartActions())
            {
                String cartId = usersShoppingCart.GetCartId();
                usersShoppingCart.MigrateCart(cartId, user.Id);
            }

            manager.Delete(user);

            IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);



        }
        else
        {
            ErrorMessage.Text = result.Errors.FirstOrDefault();
        }



    }
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
thx
Swatantra BhargavaTechnical Specialist/Developer

Commented:
No comments of Author, so closing the question.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial