diff --git a/modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs b/modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs index eba47666a4..0c3073929b 100644 --- a/modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs +++ b/modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs @@ -19,7 +19,7 @@ namespace Volo.Abp.Account { var user = new IdentityUser(GuidGenerator.Create(), input.UserName, input.EmailAddress, CurrentTenant.Id); - (await UserManager.CreateAsync(user, input.Password)).CheckErrors(); + (await UserManager.CreateAsync(user, input.Password).ConfigureAwait(false)).CheckErrors(); return ObjectMapper.Map(user); } diff --git a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs index f1abf44750..e6cdf78654 100644 --- a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs +++ b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs @@ -46,7 +46,7 @@ namespace Volo.Abp.Account.Web.Pages.Account { LoginInput = new LoginInputModel(); - var context = await Interaction.GetAuthorizationContextAsync(ReturnUrl); + var context = await Interaction.GetAuthorizationContextAsync(ReturnUrl).ConfigureAwait(false); if (context != null) { @@ -68,7 +68,7 @@ namespace Volo.Abp.Account.Web.Pages.Account return Page(); } - var schemes = await _schemeProvider.GetAllSchemesAsync(); + var schemes = await _schemeProvider.GetAllSchemesAsync().ConfigureAwait(false); var providers = schemes .Where(x => x.DisplayName != null || x.Name.Equals(_accountOptions.WindowsAuthenticationSchemeName, StringComparison.OrdinalIgnoreCase)) @@ -79,10 +79,10 @@ namespace Volo.Abp.Account.Web.Pages.Account }) .ToList(); - EnableLocalLogin = await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin); + EnableLocalLogin = await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin).ConfigureAwait(false); if (context?.ClientId != null) { - var client = await ClientStore.FindEnabledClientByIdAsync(context.ClientId); + var client = await ClientStore.FindEnabledClientByIdAsync(context.ClientId).ConfigureAwait(false); if (client != null) { EnableLocalLogin = client.EnableLocalLogin; @@ -98,7 +98,7 @@ namespace Volo.Abp.Account.Web.Pages.Account if (IsExternalLoginOnly) { - return await base.OnPostExternalLogin(providers.First().AuthenticationScheme); + return await base.OnPostExternalLogin(providers.First().AuthenticationScheme).ConfigureAwait(false); } return Page(); @@ -107,31 +107,31 @@ namespace Volo.Abp.Account.Web.Pages.Account [UnitOfWork] //TODO: Will be removed when we implement action filter public override async Task OnPostAsync(string action) { - EnableLocalLogin = await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin); + EnableLocalLogin = await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin).ConfigureAwait(false); if (action == "Cancel") { - var context = await Interaction.GetAuthorizationContextAsync(ReturnUrl); + var context = await Interaction.GetAuthorizationContextAsync(ReturnUrl).ConfigureAwait(false); if (context == null) { return Redirect("~/"); } - await Interaction.GrantConsentAsync(context, ConsentResponse.Denied); + await Interaction.GrantConsentAsync(context, ConsentResponse.Denied).ConfigureAwait(false); return Redirect(ReturnUrl); } ValidateModel(); - await ReplaceEmailToUsernameOfInputIfNeeds(); + await ReplaceEmailToUsernameOfInputIfNeeds().ConfigureAwait(false); var result = await SignInManager.PasswordSignInAsync( LoginInput.UserNameOrEmailAddress, LoginInput.Password, LoginInput.RememberMe, true - ); + ).ConfigureAwait(false); if (result.RequiresTwoFactor) { @@ -162,11 +162,11 @@ namespace Volo.Abp.Account.Web.Pages.Account } //TODO: Find a way of getting user's id from the logged in user and do not query it again like that! - var user = await UserManager.FindByNameAsync(LoginInput.UserNameOrEmailAddress) ?? - await UserManager.FindByEmailAsync(LoginInput.UserNameOrEmailAddress); + var user = await UserManager.FindByNameAsync(LoginInput.UserNameOrEmailAddress).ConfigureAwait(false) ?? + await UserManager.FindByEmailAsync(LoginInput.UserNameOrEmailAddress).ConfigureAwait(false); Debug.Assert(user != null, nameof(user) + " != null"); - await IdentityServerEvents.RaiseAsync(new UserLoginSuccessEvent(user.UserName, user.Id.ToString(), user.UserName)); //TODO: Use user's name once implemented + await IdentityServerEvents.RaiseAsync(new UserLoginSuccessEvent(user.UserName, user.Id.ToString(), user.UserName)).ConfigureAwait(false); //TODO: Use user's name once implemented return RedirectSafely(ReturnUrl, ReturnUrlHash); } @@ -176,15 +176,15 @@ namespace Volo.Abp.Account.Web.Pages.Account { if (_accountOptions.WindowsAuthenticationSchemeName == provider) { - return await ProcessWindowsLoginAsync(); + return await ProcessWindowsLoginAsync().ConfigureAwait(false); } - return await base.OnPostExternalLogin(provider); + return await base.OnPostExternalLogin(provider).ConfigureAwait(false); } private async Task ProcessWindowsLoginAsync() { - var result = await HttpContext.AuthenticateAsync(_accountOptions.WindowsAuthenticationSchemeName); + var result = await HttpContext.AuthenticateAsync(_accountOptions.WindowsAuthenticationSchemeName).ConfigureAwait(false); if (!(result?.Principal is WindowsPrincipal windowsPrincipal)) { return Challenge(_accountOptions.WindowsAuthenticationSchemeName); @@ -219,7 +219,7 @@ namespace Volo.Abp.Account.Web.Pages.Account IdentityServer4.IdentityServerConstants.ExternalCookieAuthenticationScheme, new ClaimsPrincipal(identity), props - ); + ).ConfigureAwait(false); return RedirectSafely(props.RedirectUri); } diff --git a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Consent.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Consent.cshtml.cs index 3fb68feaca..e34f6e98f1 100644 --- a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Consent.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Consent.cshtml.cs @@ -44,19 +44,19 @@ namespace Volo.Abp.Account.Web.Pages public virtual async Task OnGet() { - var request = await _interaction.GetAuthorizationContextAsync(ReturnUrl); + var request = await _interaction.GetAuthorizationContextAsync(ReturnUrl).ConfigureAwait(false); if (request == null) { throw new ApplicationException($"No consent request matching request: {ReturnUrl}"); } - var client = await _clientStore.FindEnabledClientByIdAsync(request.ClientId); + var client = await _clientStore.FindEnabledClientByIdAsync(request.ClientId).ConfigureAwait(false); if (client == null) { throw new ApplicationException($"Invalid client id: {request.ClientId}"); } - var resources = await _resourceStore.FindEnabledResourcesByScopeAsync(request.ScopesRequested); + var resources = await _resourceStore.FindEnabledResourcesByScopeAsync(request.ScopesRequested).ConfigureAwait(false); if (resources == null || (!resources.IdentityResources.Any() && !resources.ApiResources.Any())) { throw new ApplicationException($"No scopes matching: {request.ScopesRequested.Aggregate((x, y) => x + ", " + y)}"); @@ -78,7 +78,7 @@ namespace Volo.Abp.Account.Web.Pages public virtual async Task OnPost(string userDecision) { - var result = await ProcessConsentAsync(); + var result = await ProcessConsentAsync().ConfigureAwait(false); if (result.IsRedirect) { @@ -122,13 +122,13 @@ namespace Volo.Abp.Account.Web.Pages if (grantedConsent != null) { - var request = await _interaction.GetAuthorizationContextAsync(ReturnUrl); + var request = await _interaction.GetAuthorizationContextAsync(ReturnUrl).ConfigureAwait(false); if (request == null) { return result; } - await _interaction.GrantConsentAsync(request, grantedConsent); + await _interaction.GrantConsentAsync(request, grantedConsent).ConfigureAwait(false); result.RedirectUri = ReturnUrl; //TODO: ReturnUrlHash? } diff --git a/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/AccountController.cs b/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/AccountController.cs index 05f37067d4..12960920c8 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/AccountController.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/AccountController.cs @@ -34,14 +34,14 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers { ValidateLoginInfo(login); - await ReplaceEmailToUsernameOfInputIfNeeds(login); + await ReplaceEmailToUsernameOfInputIfNeeds(login).ConfigureAwait(false); return GetAbpLoginResult(await _signInManager.PasswordSignInAsync( login.UserNameOrEmailAddress, login.Password, login.RememberMe, true - )); + ).ConfigureAwait(false)); } [HttpPost] @@ -50,16 +50,16 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers { ValidateLoginInfo(login); - await ReplaceEmailToUsernameOfInputIfNeeds(login); + await ReplaceEmailToUsernameOfInputIfNeeds(login).ConfigureAwait(false); - var identityUser = await _userManager.FindByNameAsync(login.UserNameOrEmailAddress); + var identityUser = await _userManager.FindByNameAsync(login.UserNameOrEmailAddress).ConfigureAwait(false); if (identityUser == null) { return new AbpLoginResult(LoginResultType.InvalidUserNameOrPassword); } - return GetAbpLoginResult(await _signInManager.CheckPasswordSignInAsync(identityUser, login.Password, true)); + return GetAbpLoginResult(await _signInManager.CheckPasswordSignInAsync(identityUser, login.Password, true).ConfigureAwait(false)); } protected virtual async Task ReplaceEmailToUsernameOfInputIfNeeds(UserLoginInfo login) @@ -69,13 +69,13 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers return; } - var userByUsername = await _userManager.FindByNameAsync(login.UserNameOrEmailAddress); + var userByUsername = await _userManager.FindByNameAsync(login.UserNameOrEmailAddress).ConfigureAwait(false); if (userByUsername != null) { return; } - var userByEmail = await _userManager.FindByEmailAsync(login.UserNameOrEmailAddress); + var userByEmail = await _userManager.FindByEmailAsync(login.UserNameOrEmailAddress).ConfigureAwait(false); if (userByEmail == null) { return; diff --git a/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/LogoutController.cs b/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/LogoutController.cs index eb7d1cbc84..878f2aa2d5 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/LogoutController.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/LogoutController.cs @@ -19,7 +19,7 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers //todo@alper: this method can be moved to AccountController like "account/logout" public async Task Index(string returnUrl = null) { - await _signInManager.SignOutAsync(); + await _signInManager.SignOutAsync().ConfigureAwait(false); if (returnUrl != null) { diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs index e7e625416a..262d3ccfcf 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs @@ -62,7 +62,7 @@ namespace Volo.Abp.Account.Web.Pages.Account { LoginInput = new LoginInputModel(); - var schemes = await _schemeProvider.GetAllSchemesAsync(); + var schemes = await _schemeProvider.GetAllSchemesAsync().ConfigureAwait(false); var providers = schemes .Where(x => x.DisplayName != null || x.Name.Equals(_accountOptions.WindowsAuthenticationSchemeName, StringComparison.OrdinalIgnoreCase)) @@ -73,7 +73,7 @@ namespace Volo.Abp.Account.Web.Pages.Account }) .ToList(); - EnableLocalLogin = await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin); + EnableLocalLogin = await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin).ConfigureAwait(false); ExternalProviders = providers.ToArray(); @@ -89,18 +89,18 @@ namespace Volo.Abp.Account.Web.Pages.Account [UnitOfWork] //TODO: Will be removed when we implement action filter public virtual async Task OnPostAsync(string action) { - EnableLocalLogin = await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin); + EnableLocalLogin = await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin).ConfigureAwait(false); ValidateModel(); - await ReplaceEmailToUsernameOfInputIfNeeds(); + await ReplaceEmailToUsernameOfInputIfNeeds().ConfigureAwait(false); var result = await SignInManager.PasswordSignInAsync( LoginInput.UserNameOrEmailAddress, LoginInput.Password, LoginInput.RememberMe, true - ); + ).ConfigureAwait(false); if (result.RequiresTwoFactor) { @@ -131,8 +131,8 @@ namespace Volo.Abp.Account.Web.Pages.Account } //TODO: Find a way of getting user's id from the logged in user and do not query it again like that! - var user = await UserManager.FindByNameAsync(LoginInput.UserNameOrEmailAddress) ?? - await UserManager.FindByEmailAsync(LoginInput.UserNameOrEmailAddress); + var user = await UserManager.FindByNameAsync(LoginInput.UserNameOrEmailAddress).ConfigureAwait(false) ?? + await UserManager.FindByEmailAsync(LoginInput.UserNameOrEmailAddress).ConfigureAwait(false); Debug.Assert(user != null, nameof(user) + " != null"); @@ -163,7 +163,7 @@ namespace Volo.Abp.Account.Web.Pages.Account return RedirectToPage("./Login"); } - var loginInfo = await SignInManager.GetExternalLoginInfoAsync(); + var loginInfo = await SignInManager.GetExternalLoginInfoAsync().ConfigureAwait(false); if (loginInfo == null) { Logger.LogWarning("External login info is not available"); @@ -175,7 +175,7 @@ namespace Volo.Abp.Account.Web.Pages.Account loginInfo.ProviderKey, isPersistent: false, bypassTwoFactor: true - ); + ).ConfigureAwait(false); if (result.IsLockedOut) { @@ -190,15 +190,15 @@ namespace Volo.Abp.Account.Web.Pages.Account //TODO: Handle other cases for result! // Get the information about the user from the external login provider - var info = await SignInManager.GetExternalLoginInfoAsync(); + var info = await SignInManager.GetExternalLoginInfoAsync().ConfigureAwait(false); if (info == null) { throw new ApplicationException("Error loading external login information during confirmation."); } - var user = await CreateExternalUserAsync(info); + var user = await CreateExternalUserAsync(info).ConfigureAwait(false); - await SignInManager.SignInAsync(user, false); + await SignInManager.SignInAsync(user, false).ConfigureAwait(false); return RedirectSafely(returnUrl, returnUrlHash); } @@ -208,9 +208,9 @@ namespace Volo.Abp.Account.Web.Pages.Account var user = new IdentityUser(GuidGenerator.Create(), emailAddress, emailAddress, CurrentTenant.Id); - CheckIdentityErrors(await UserManager.CreateAsync(user)); - CheckIdentityErrors(await UserManager.SetEmailAsync(user, emailAddress)); - CheckIdentityErrors(await UserManager.AddLoginAsync(user, info)); + CheckIdentityErrors(await UserManager.CreateAsync(user).ConfigureAwait(false)); + CheckIdentityErrors(await UserManager.SetEmailAsync(user, emailAddress).ConfigureAwait(false)); + CheckIdentityErrors(await UserManager.AddLoginAsync(user, info).ConfigureAwait(false)); return user; } @@ -222,13 +222,13 @@ namespace Volo.Abp.Account.Web.Pages.Account return; } - var userByUsername = await UserManager.FindByNameAsync(LoginInput.UserNameOrEmailAddress); + var userByUsername = await UserManager.FindByNameAsync(LoginInput.UserNameOrEmailAddress).ConfigureAwait(false); if (userByUsername != null) { return; } - var userByEmail = await UserManager.FindByEmailAsync(LoginInput.UserNameOrEmailAddress); + var userByEmail = await UserManager.FindByEmailAsync(LoginInput.UserNameOrEmailAddress).ConfigureAwait(false); if (userByEmail == null) { return; diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs index 9fba470929..7c94f747cd 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs @@ -19,7 +19,7 @@ namespace Volo.Abp.Account.Web.Pages.Account public async Task OnGetAsync() { - var user = await _profileAppService.GetAsync(); + var user = await _profileAppService.GetAsync().ConfigureAwait(false); PersonalSettingsInfoModel = ObjectMapper.Map(user); } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs index 1a16cecc2a..f85ee25f6f 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs @@ -22,7 +22,7 @@ namespace Volo.Abp.Account.Web.Pages.Account public virtual async Task OnGet() { - await CheckSelfRegistrationAsync(); + await CheckSelfRegistrationAsync().ConfigureAwait(false); } [UnitOfWork] //TODO: Will be removed when we implement action filter @@ -30,22 +30,22 @@ namespace Volo.Abp.Account.Web.Pages.Account { ValidateModel(); - await CheckSelfRegistrationAsync(); + await CheckSelfRegistrationAsync().ConfigureAwait(false); var user = new IdentityUser(GuidGenerator.Create(), Input.UserName, Input.EmailAddress, CurrentTenant.Id); - (await UserManager.CreateAsync(user, Input.Password)).CheckErrors(); - - await UserManager.SetEmailAsync(user, Input.EmailAddress); + (await UserManager.CreateAsync(user, Input.Password).ConfigureAwait(false)).CheckErrors(); + + await UserManager.SetEmailAsync(user, Input.EmailAddress).ConfigureAwait(false); - await SignInManager.SignInAsync(user, isPersistent: false); + await SignInManager.SignInAsync(user, isPersistent: false).ConfigureAwait(false); return Redirect(ReturnUrl ?? "/"); //TODO: How to ensure safety? IdentityServer requires it however it should be checked somehow! } protected virtual async Task CheckSelfRegistrationAsync() { - if (!await SettingProvider.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled)) + if (!await SettingProvider.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled).ConfigureAwait(false)) { throw new UserFriendlyException(L["SelfRegistrationDisabledMessage"]); } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/SendSecurityCode.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/SendSecurityCode.cshtml.cs index 5923d8972c..ab8abd4853 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/SendSecurityCode.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/SendSecurityCode.cshtml.cs @@ -14,7 +14,7 @@ namespace Volo.Abp.Account.Web.Pages.Account public async Task OnGetAsync() { - var user = await SignInManager.GetTwoFactorAuthenticationUserAsync(); + var user = await SignInManager.GetTwoFactorAuthenticationUserAsync().ConfigureAwait(false); if (user == null) { return RedirectToPage("./Login"); diff --git a/modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AccountAppService_Tests.cs b/modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AccountAppService_Tests.cs index 634cbfc253..0de397b70c 100644 --- a/modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AccountAppService_Tests.cs +++ b/modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AccountAppService_Tests.cs @@ -33,16 +33,16 @@ namespace Volo.Abp.Account.Pro.Application.Tests.Volo.Abp.Account AppName = "MVC" }; - await _accountAppService.RegisterAsync(registerDto); + await _accountAppService.RegisterAsync(registerDto).ConfigureAwait(false); var user = await _identityUserRepository.FindByNormalizedUserNameAsync( - _lookupNormalizer.NormalizeName("bob.lee")); + _lookupNormalizer.NormalizeName("bob.lee")).ConfigureAwait(false); user.ShouldNotBeNull(); user.UserName.ShouldBe("bob.lee"); user.Email.ShouldBe("bob.lee@abp.io"); - (await _userManager.CheckPasswordAsync(user, "P@ssW0rd")).ShouldBeTrue(); + (await _userManager.CheckPasswordAsync(user, "P@ssW0rd").ConfigureAwait(false)).ShouldBeTrue(); } } }