From ea1a08bca8c6b2ee79b1c3c5264dfe556868d9b1 Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Wed, 3 Jan 2018 13:04:47 +0300 Subject: [PATCH] Removed register page during Facebook authentication --- .../Pages/Account/ExternalLogin.cshtml.cs | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Volo.Abp.Account.Web/Pages/Account/ExternalLogin.cshtml.cs b/src/Volo.Abp.Account.Web/Pages/Account/ExternalLogin.cshtml.cs index 7e08a7a805..ccbe25a167 100644 --- a/src/Volo.Abp.Account.Web/Pages/Account/ExternalLogin.cshtml.cs +++ b/src/Volo.Abp.Account.Web/Pages/Account/ExternalLogin.cshtml.cs @@ -82,18 +82,18 @@ namespace Volo.Abp.Account.Web.Pages.Account // If the user does not have an account, then ask the user to create an account. ReturnUrl = returnUrl; LoginProvider = info.LoginProvider; - if (info.Principal.HasClaim(c => c.Type == ClaimTypes.Email)) + var success = await CreateUserAsync(returnUrl, returnUrlHash); + + if (success) { - Input = new InputModel - { - Email = info.Principal.FindFirstValue(ClaimTypes.Email) - }; + return RedirectSafely(returnUrl, returnUrlHash); } + return Page(); } [UnitOfWork] - public virtual async Task OnPostConfirmationAsync(string returnUrl = null, string returnUrlHash = null) + public virtual async Task CreateUserAsync(string returnUrl = null, string returnUrlHash = null) { if (ModelState.IsValid) { @@ -104,7 +104,7 @@ namespace Volo.Abp.Account.Web.Pages.Account throw new ApplicationException("Error loading external login information during confirmation."); } - var user = new IdentityUser(GuidGenerator.Create(), Input.Email); + var user = new IdentityUser(GuidGenerator.Create(), info.Principal.FindFirstValue(ClaimTypes.Email)); var result = await _userManager.CreateAsync(user); @@ -117,17 +117,18 @@ namespace Volo.Abp.Account.Web.Pages.Account { await _signInManager.SignInAsync(user, isPersistent: false); - return RedirectSafely(returnUrl, returnUrlHash); + return true; } } + foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } - ReturnUrl = returnUrl; - return Page(); + return false; + } } } \ No newline at end of file