Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email .... is already taken #12

Closed
lifeact opened this issue Nov 29, 2017 · 0 comments
Closed

Email .... is already taken #12

lifeact opened this issue Nov 29, 2017 · 0 comments

Comments

@lifeact
Copy link

lifeact commented Nov 29, 2017

Hi, thise my code:

View:
`
....
@Html.TextBoxFor(m => m.LoginVK, new { @Class = "form-control" })
@Html.ValidationMessageFor(m => m.LoginVK, "", new { @Class = "text-danger" })

                        @Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" })

....
Controller:
...
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl)
{

        try
        {

            if (User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Manage");
            }

            if (ModelState.IsValid)
            {
                // Get the information about the user from the external login provider
                var info = await AuthenticationManager.GetExternalLoginInfoAsync();
                if (info == null)
                {
                    return View("ExternalLoginFailure");
                }
                var user = new ApplicationUser() { UserName = model.LoginVK, Email = model.Email };
                var result = await UserManager.CreateAsync(user);
                if (result.Succeeded)
                {
                    result = await UserManager.AddLoginAsync(user.Id, info.Login);
                    if (result.Succeeded)
                    {
                        
                        await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                        return RedirectToLocal(returnUrl);
                    }
                }
                AddErrors(result);
            }

            ViewBag.ReturnUrl = returnUrl;
            return View(model);

        }

}
...
`
When I click "Войти", I have the error:
Email 'ds......@mail.ua' is already taken
Where my mistake?
xnview - register - google chrome png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants