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 35d812806f..e2e4206b81 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 @@ -10,14 +10,14 @@ namespace Volo.Abp.Account { public class AccountAppService : ApplicationService, IAccountAppService { - private readonly IIdentityRoleRepository _roleRepository; + protected IIdentityRoleRepository RoleRepository { get; } protected IdentityUserManager UserManager { get; } public AccountAppService( IdentityUserManager userManager, IIdentityRoleRepository roleRepository) { - _roleRepository = roleRepository; + RoleRepository = roleRepository; UserManager = userManager; } @@ -43,4 +43,4 @@ namespace Volo.Abp.Account } } } -} +} \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AccountController.cs b/modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AccountController.cs index c750ede454..e175607842 100644 --- a/modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AccountController.cs +++ b/modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AccountController.cs @@ -10,18 +10,18 @@ namespace Volo.Abp.Account [Route("api/account")] public class AccountController : AbpController, IAccountAppService { - private readonly IAccountAppService _accountAppService; + protected IAccountAppService AccountAppService { get; } public AccountController(IAccountAppService accountAppService) { - _accountAppService = accountAppService; + AccountAppService = accountAppService; } [HttpPost] [Route("register")] - public Task RegisterAsync(RegisterDto input) + public virtual Task RegisterAsync(RegisterDto input) { - return _accountAppService.RegisterAsync(input); + return AccountAppService.RegisterAsync(input); } } } \ No newline at end of file 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 c2e50a2317..179e18246a 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 @@ -68,10 +68,10 @@ namespace Volo.Abp.Account.Web.Pages.Account return Page(); } - var schemes = await _schemeProvider.GetAllSchemesAsync(); + var schemes = await SchemeProvider.GetAllSchemesAsync(); var providers = schemes - .Where(x => x.DisplayName != null || x.Name.Equals(_accountOptions.WindowsAuthenticationSchemeName, StringComparison.OrdinalIgnoreCase)) + .Where(x => x.DisplayName != null || x.Name.Equals(AccountOptions.WindowsAuthenticationSchemeName, StringComparison.OrdinalIgnoreCase)) .Select(x => new ExternalProviderModel { DisplayName = x.DisplayName, @@ -174,7 +174,7 @@ namespace Volo.Abp.Account.Web.Pages.Account [UnitOfWork] public override async Task OnPostExternalLogin(string provider) { - if (_accountOptions.WindowsAuthenticationSchemeName == provider) + if (AccountOptions.WindowsAuthenticationSchemeName == provider) { return await ProcessWindowsLoginAsync(); } @@ -184,10 +184,10 @@ namespace Volo.Abp.Account.Web.Pages.Account private async Task ProcessWindowsLoginAsync() { - var result = await HttpContext.AuthenticateAsync(_accountOptions.WindowsAuthenticationSchemeName); + var result = await HttpContext.AuthenticateAsync(AccountOptions.WindowsAuthenticationSchemeName); if (!(result?.Principal is WindowsPrincipal windowsPrincipal)) { - return Challenge(_accountOptions.WindowsAuthenticationSchemeName); + return Challenge(AccountOptions.WindowsAuthenticationSchemeName); } var props = new AuthenticationProperties @@ -195,11 +195,11 @@ namespace Volo.Abp.Account.Web.Pages.Account RedirectUri = Url.Page("./Login", pageHandler: "ExternalLoginCallback", values: new { ReturnUrl, ReturnUrlHash }), Items = { - {"scheme", _accountOptions.WindowsAuthenticationSchemeName}, + {"scheme", AccountOptions.WindowsAuthenticationSchemeName}, } }; - var identity = new ClaimsIdentity(_accountOptions.WindowsAuthenticationSchemeName); + var identity = new ClaimsIdentity(AccountOptions.WindowsAuthenticationSchemeName); identity.AddClaim(new Claim(JwtClaimTypes.Subject, windowsPrincipal.Identity.Name)); identity.AddClaim(new Claim(JwtClaimTypes.Name, windowsPrincipal.Identity.Name)); diff --git a/modules/account/src/Volo.Abp.Account.Web/AbpAccountUserMenuContributor.cs b/modules/account/src/Volo.Abp.Account.Web/AbpAccountUserMenuContributor.cs index 9bdd8095ed..20c42cc4c1 100644 --- a/modules/account/src/Volo.Abp.Account.Web/AbpAccountUserMenuContributor.cs +++ b/modules/account/src/Volo.Abp.Account.Web/AbpAccountUserMenuContributor.cs @@ -9,7 +9,7 @@ namespace Volo.Abp.Account.Web { public class AbpAccountUserMenuContributor : IMenuContributor { - public Task ConfigureMenuAsync(MenuConfigurationContext context) + public virtual Task ConfigureMenuAsync(MenuConfigurationContext context) { if (context.Menu.Name != StandardMenus.User) { diff --git a/modules/account/src/Volo.Abp.Account.Web/AccountModuleToolbarContributor.cs b/modules/account/src/Volo.Abp.Account.Web/AccountModuleToolbarContributor.cs index 1d85f06521..1bade3f661 100644 --- a/modules/account/src/Volo.Abp.Account.Web/AccountModuleToolbarContributor.cs +++ b/modules/account/src/Volo.Abp.Account.Web/AccountModuleToolbarContributor.cs @@ -8,7 +8,7 @@ namespace Volo.Abp.Account.Web { public class AccountModuleToolbarContributor : IToolbarContributor { - public Task ConfigureToolbarAsync(IToolbarConfigurationContext context) + public virtual Task ConfigureToolbarAsync(IToolbarConfigurationContext context) { if (context.Toolbar.Name != StandardToolbars.Main) { 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 d916368c39..4a1689e8e9 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 @@ -22,17 +22,17 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers [Route("api/account")] public class AccountController : AbpController { - private readonly SignInManager _signInManager; - private readonly IdentityUserManager _userManager; - private readonly ISettingProvider _settingProvider; + protected SignInManager SignInManager { get; } + protected IdentityUserManager UserManager { get; } + protected ISettingProvider SettingProvider { get; } public AccountController(SignInManager signInManager, IdentityUserManager userManager, ISettingProvider settingProvider) { LocalizationResource = typeof(AccountResource); - _signInManager = signInManager; - _userManager = userManager; - _settingProvider = settingProvider; + SignInManager = signInManager; + UserManager = userManager; + SettingProvider = settingProvider; } [HttpPost] @@ -45,7 +45,7 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers await ReplaceEmailToUsernameOfInputIfNeeds(login); - return GetAbpLoginResult(await _signInManager.PasswordSignInAsync( + return GetAbpLoginResult(await SignInManager.PasswordSignInAsync( login.UserNameOrEmailAddress, login.Password, login.RememberMe, @@ -57,7 +57,7 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers [Route("logout")] public virtual async Task Logout() { - await _signInManager.SignOutAsync(); + await SignInManager.SignOutAsync(); } [HttpPost] @@ -68,14 +68,14 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers await ReplaceEmailToUsernameOfInputIfNeeds(login); - var identityUser = await _userManager.FindByNameAsync(login.UserNameOrEmailAddress); + var identityUser = await UserManager.FindByNameAsync(login.UserNameOrEmailAddress); 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)); } protected virtual async Task ReplaceEmailToUsernameOfInputIfNeeds(UserLoginInfo login) @@ -85,13 +85,13 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers return; } - var userByUsername = await _userManager.FindByNameAsync(login.UserNameOrEmailAddress); + var userByUsername = await UserManager.FindByNameAsync(login.UserNameOrEmailAddress); if (userByUsername != null) { return; } - var userByEmail = await _userManager.FindByEmailAsync(login.UserNameOrEmailAddress); + var userByEmail = await UserManager.FindByEmailAsync(login.UserNameOrEmailAddress); if (userByEmail == null) { return; @@ -125,7 +125,7 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers return new AbpLoginResult(LoginResultType.Success); } - private void ValidateLoginInfo(UserLoginInfo login) + protected virtual void ValidateLoginInfo(UserLoginInfo login) { if (login == null) { @@ -143,9 +143,9 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers } } - private async Task CheckLocalLoginAsync() + protected virtual async Task CheckLocalLoginAsync() { - if (!await _settingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin)) + if (!await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin)) { throw new UserFriendlyException(L["LocalLoginDisabledMessage"]); } diff --git a/modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/UserLoginLinkViewComponent.cs b/modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/UserLoginLinkViewComponent.cs index 888f8c2925..3c71ca510c 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/UserLoginLinkViewComponent.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/UserLoginLinkViewComponent.cs @@ -5,7 +5,7 @@ namespace Volo.Abp.Account.Web.Modules.Account.Components.Toolbar.UserLoginLink { public class UserLoginLinkViewComponent : AbpViewComponent { - public IViewComponentResult Invoke() + public virtual IViewComponentResult Invoke() { return View("~/Modules/Account/Components/Toolbar/UserLoginLink/Default.cshtml"); } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccountPageModel.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccountPageModel.cs index e10b1fecdc..f5dbba8b2f 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccountPageModel.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccountPageModel.cs @@ -21,12 +21,12 @@ namespace Volo.Abp.Account.Web.Pages.Account ObjectMapperContext = typeof(AbpAccountWebModule); } - protected RedirectResult RedirectSafely(string returnUrl, string returnUrlHash = null) + protected virtual RedirectResult RedirectSafely(string returnUrl, string returnUrlHash = null) { return Redirect(GetRedirectUrl(returnUrl, returnUrlHash)); } - protected void CheckIdentityErrors(IdentityResult identityResult) + protected virtual void CheckIdentityErrors(IdentityResult identityResult) { if (!identityResult.Succeeded) { @@ -36,7 +36,7 @@ namespace Volo.Abp.Account.Web.Pages.Account //identityResult.CheckErrors(LocalizationManager); //TODO: Get from old Abp } - private string GetRedirectUrl(string returnUrl, string returnUrlHash = null) + protected virtual string GetRedirectUrl(string returnUrl, string returnUrlHash = null) { returnUrl = NormalizeReturnUrl(returnUrl); @@ -48,7 +48,7 @@ namespace Volo.Abp.Account.Web.Pages.Account return returnUrl; } - private string NormalizeReturnUrl(string returnUrl) + protected virtual string NormalizeReturnUrl(string returnUrl) { if (returnUrl.IsNullOrEmpty()) { 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 7d92131eef..68aef8ee4c 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 @@ -48,25 +48,25 @@ namespace Volo.Abp.Account.Web.Pages.Account //public IClientStore ClientStore { get; set; } //public IEventService IdentityServerEvents { get; set; } - protected IAuthenticationSchemeProvider _schemeProvider; - protected AbpAccountOptions _accountOptions; + protected IAuthenticationSchemeProvider SchemeProvider { get; } + protected AbpAccountOptions AccountOptions { get; } public LoginModel( IAuthenticationSchemeProvider schemeProvider, IOptions accountOptions) { - _schemeProvider = schemeProvider; - _accountOptions = accountOptions.Value; + SchemeProvider = schemeProvider; + AccountOptions = accountOptions.Value; } public virtual async Task OnGetAsync() { LoginInput = new LoginInputModel(); - var schemes = await _schemeProvider.GetAllSchemesAsync(); + var schemes = await SchemeProvider.GetAllSchemesAsync(); var providers = schemes - .Where(x => x.DisplayName != null || x.Name.Equals(_accountOptions.WindowsAuthenticationSchemeName, StringComparison.OrdinalIgnoreCase)) + .Where(x => x.DisplayName != null || x.Name.Equals(AccountOptions.WindowsAuthenticationSchemeName, StringComparison.OrdinalIgnoreCase)) .Select(x => new ExternalProviderModel { DisplayName = x.DisplayName, diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Logout.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Logout.cshtml.cs index 8245cc5a77..de62eb370d 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Logout.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Logout.cshtml.cs @@ -23,5 +23,10 @@ namespace Volo.Abp.Account.Web.Pages.Account return RedirectToPage("/Account/Login"); } + + public virtual Task OnPostAsync() + { + return Task.CompletedTask; + } } } 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..58614de744 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 @@ -10,19 +10,24 @@ namespace Volo.Abp.Account.Web.Pages.Account public PersonalSettingsInfoModel PersonalSettingsInfoModel { get; set; } - private readonly IProfileAppService _profileAppService; + protected IProfileAppService ProfileAppService { get; } public ManageModel(IProfileAppService profileAppService) { - _profileAppService = profileAppService; + ProfileAppService = profileAppService; } - public async Task OnGetAsync() + public virtual async Task OnGetAsync() { - var user = await _profileAppService.GetAsync(); + var user = await ProfileAppService.GetAsync(); PersonalSettingsInfoModel = ObjectMapper.Map(user); } + + public virtual Task OnPostAsync() + { + return Task.CompletedTask; + } } public class ChangePasswordInfoModel 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 7e47c55367..0cb71f2ed9 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 @@ -15,7 +15,7 @@ namespace Volo.Abp.Account.Web.Pages.Account { public class RegisterModel : AccountPageModel { - private readonly IAccountAppService _accountAppService; + protected IAccountAppService AccountAppService { get; } [BindProperty(SupportsGet = true)] public string ReturnUrl { get; set; } @@ -28,7 +28,7 @@ namespace Volo.Abp.Account.Web.Pages.Account public RegisterModel(IAccountAppService accountAppService) { - _accountAppService = accountAppService; + AccountAppService = accountAppService; } public virtual async Task OnGetAsync() @@ -51,7 +51,7 @@ namespace Volo.Abp.Account.Web.Pages.Account UserName = Input.UserName }; - var userDto = await _accountAppService.RegisterAsync(registerDto); + var userDto = await AccountAppService.RegisterAsync(registerDto); var user = await UserManager.GetByIdAsync(userDto.Id); await UserManager.SetEmailAsync(user, Input.EmailAddress); 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..94a52cd0bd 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 @@ -12,7 +12,7 @@ namespace Volo.Abp.Account.Web.Pages.Account { public List Providers { get; set; } - public async Task OnGetAsync() + public virtual async Task OnGetAsync() { var user = await SignInManager.GetTwoFactorAuthenticationUserAsync(); if (user == null) @@ -41,5 +41,9 @@ namespace Volo.Abp.Account.Web.Pages.Account //); } + public virtual Task OnPostAsync() + { + return Task.CompletedTask; + } } } \ No newline at end of file