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

Refactor methods #20220

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public override void ConfigureServices(ServiceConfigurationContext context)
});
}

public override void PostConfigureServices(ServiceConfigurationContext context)
{
public override void PostConfigureServices(ServiceConfigurationContext context)=>
OneTimeRunner.Run(() =>
{
ModuleExtensionConfigurationHelper.ApplyEntityConfigurationToApi(
Expand All @@ -50,5 +49,5 @@ public override void PostConfigureServices(ServiceConfigurationContext context)
updateApiTypes: new[] { typeof(UpdateProfileDto) }
);
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ namespace Volo.Abp.Account;

public class AbpAccountApplicationModuleAutoMapperProfile : Profile
{
public AbpAccountApplicationModuleAutoMapperProfile()
{
public AbpAccountApplicationModuleAutoMapperProfile() =>
CreateMap<IdentityUser, ProfileDto>()
.ForMember(dest => dest.HasPassword,
op => op.MapFrom(src => src.PasswordHash != null))
.MapExtraProperties();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,14 @@
namespace Volo.Abp.Account;

[Authorize]
public class DynamicClaimsAppService : IdentityAppServiceBase, IDynamicClaimsAppService
public class DynamicClaimsAppService(
IdentityDynamicClaimsPrincipalContributorCache identityDynamicClaimsPrincipalContributorCache,
IAbpClaimsPrincipalFactory abpClaimsPrincipalFactory,
ICurrentPrincipalAccessor principalAccessor) : IdentityAppServiceBase, IDynamicClaimsAppService
{
protected IdentityDynamicClaimsPrincipalContributorCache IdentityDynamicClaimsPrincipalContributorCache { get; }
protected IAbpClaimsPrincipalFactory AbpClaimsPrincipalFactory { get; }
protected ICurrentPrincipalAccessor PrincipalAccessor { get; }

public DynamicClaimsAppService(
IdentityDynamicClaimsPrincipalContributorCache identityDynamicClaimsPrincipalContributorCache,
IAbpClaimsPrincipalFactory abpClaimsPrincipalFactory,
ICurrentPrincipalAccessor principalAccessor)
{
IdentityDynamicClaimsPrincipalContributorCache = identityDynamicClaimsPrincipalContributorCache;
AbpClaimsPrincipalFactory = abpClaimsPrincipalFactory;
PrincipalAccessor = principalAccessor;
}
protected IdentityDynamicClaimsPrincipalContributorCache IdentityDynamicClaimsPrincipalContributorCache { get; } = identityDynamicClaimsPrincipalContributorCache;
protected IAbpClaimsPrincipalFactory AbpClaimsPrincipalFactory { get; } = abpClaimsPrincipalFactory;
protected ICurrentPrincipalAccessor PrincipalAccessor { get; } = principalAccessor;

public virtual async Task RefreshAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,18 @@

namespace Volo.Abp.Account.Emailing;

public class AccountEmailer : IAccountEmailer, ITransientDependency
public class AccountEmailer(
IEmailSender emailSender,
ITemplateRenderer templateRenderer,
IStringLocalizer<AccountResource> stringLocalizer,
IAppUrlProvider appUrlProvider,
ICurrentTenant currentTenant) : IAccountEmailer, ITransientDependency
{
protected ITemplateRenderer TemplateRenderer { get; }
protected IEmailSender EmailSender { get; }
protected IStringLocalizer<AccountResource> StringLocalizer { get; }
protected IAppUrlProvider AppUrlProvider { get; }
protected ICurrentTenant CurrentTenant { get; }

public AccountEmailer(
IEmailSender emailSender,
ITemplateRenderer templateRenderer,
IStringLocalizer<AccountResource> stringLocalizer,
IAppUrlProvider appUrlProvider,
ICurrentTenant currentTenant)
{
EmailSender = emailSender;
StringLocalizer = stringLocalizer;
AppUrlProvider = appUrlProvider;
CurrentTenant = currentTenant;
TemplateRenderer = templateRenderer;
}
protected ITemplateRenderer TemplateRenderer { get; } = templateRenderer;
protected IEmailSender EmailSender { get; } = emailSender;
protected IStringLocalizer<AccountResource> StringLocalizer { get; } = stringLocalizer;
protected IAppUrlProvider AppUrlProvider { get; } = appUrlProvider;
protected ICurrentTenant CurrentTenant { get; } = currentTenant;

public virtual async Task SendPasswordResetLinkAsync(
IdentityUser user,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace Volo.Abp.Account.Emailing;

public static class AppUrlProviderAccountExtensions
{
public static Task<string> GetResetPasswordUrlAsync(this IAppUrlProvider appUrlProvider, string appName)
{
return appUrlProvider.GetUrlAsync(appName, AccountUrlNames.PasswordReset);
}
public static Task<string> GetResetPasswordUrlAsync(this IAppUrlProvider appUrlProvider, string appName) =>
appUrlProvider.GetUrlAsync(appName, AccountUrlNames.PasswordReset);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ namespace Volo.Abp.Account.Emailing.Templates;

public class AccountEmailTemplateDefinitionProvider : TemplateDefinitionProvider
{
public override void Define(ITemplateDefinitionContext context)
{
context.Add(
public override void Define(ITemplateDefinitionContext context) => context.Add(
new TemplateDefinition(
AccountEmailTemplates.PasswordResetLink,
displayName: LocalizableString.Create<AccountResource>($"TextTemplate:{AccountEmailTemplates.PasswordResetLink}"),
layout: StandardEmailTemplates.Layout,
localizationResource: typeof(AccountResource)
).WithVirtualFilePath("/Volo/Abp/Account/Emailing/Templates/PasswordResetLink.tpl", true)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,12 @@
namespace Volo.Abp.Account;

[Authorize]
public class ProfileAppService : IdentityAppServiceBase, IProfileAppService
public class ProfileAppService(
IdentityUserManager userManager,
IOptions<IdentityOptions> identityOptions) : IdentityAppServiceBase, IProfileAppService
{
protected IdentityUserManager UserManager { get; }
protected IOptions<IdentityOptions> IdentityOptions { get; }

public ProfileAppService(
IdentityUserManager userManager,
IOptions<IdentityOptions> identityOptions)
{
UserManager = userManager;
IdentityOptions = identityOptions;
}
protected IdentityUserManager UserManager { get; } = userManager;
protected IOptions<IdentityOptions> IdentityOptions { get; } = identityOptions;

public virtual async Task<ProfileDto> GetAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,5 @@ public override void Define(ISettingDefinitionContext context)
);
}

private static LocalizableString L(string name)
{
return LocalizableString.Create<AccountResource>(name);
}
private static LocalizableString L(string name) => LocalizableString.Create<AccountResource>(name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public override void ConfigureServices(ServiceConfigurationContext context)
});
}

public override void PostConfigureServices(ServiceConfigurationContext context)
{
public override void PostConfigureServices(ServiceConfigurationContext context)=>
OneTimeRunner.Run(() =>
{
ModuleExtensionConfigurationHelper
Expand All @@ -51,5 +50,5 @@ public override void PostConfigureServices(ServiceConfigurationContext context)
editFormTypes: new[] { typeof(PersonalInfoModel) }
);
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,27 @@ namespace Volo.Abp.Account;
[ExposeServices(typeof(IAccountAppService), typeof(AccountClientProxy))]
public partial class AccountClientProxy : ClientProxyBase<IAccountAppService>, IAccountAppService
{
public virtual async Task<IdentityUserDto> RegisterAsync(RegisterDto input)
{
return await RequestAsync<IdentityUserDto>(nameof(RegisterAsync), new ClientProxyRequestTypeValue
public virtual async Task<IdentityUserDto> RegisterAsync(RegisterDto input) =>
await RequestAsync<IdentityUserDto>(nameof(RegisterAsync), new ClientProxyRequestTypeValue
{
{ typeof(RegisterDto), input }
});
}

public virtual async Task SendPasswordResetCodeAsync(SendPasswordResetCodeDto input)
{
public virtual async Task SendPasswordResetCodeAsync(SendPasswordResetCodeDto input) =>
await RequestAsync(nameof(SendPasswordResetCodeAsync), new ClientProxyRequestTypeValue
{
{ typeof(SendPasswordResetCodeDto), input }
});
}

public virtual async Task<bool> VerifyPasswordResetTokenAsync(VerifyPasswordResetTokenInput input)
{
return await RequestAsync<bool>(nameof(VerifyPasswordResetTokenAsync), new ClientProxyRequestTypeValue
public virtual async Task<bool> VerifyPasswordResetTokenAsync(VerifyPasswordResetTokenInput input) =>
await RequestAsync<bool>(nameof(VerifyPasswordResetTokenAsync), new ClientProxyRequestTypeValue
{
{ typeof(VerifyPasswordResetTokenInput), input }
});
}

public virtual async Task ResetPasswordAsync(ResetPasswordDto input)
{
public virtual async Task ResetPasswordAsync(ResetPasswordDto input) =>
await RequestAsync(nameof(ResetPasswordAsync), new ClientProxyRequestTypeValue
{
{ typeof(ResetPasswordDto), input }
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,5 @@ namespace Volo.Abp.Account;
[ExposeServices(typeof(IDynamicClaimsAppService), typeof(DynamicClaimsClientProxy))]
public partial class DynamicClaimsClientProxy : ClientProxyBase<IDynamicClaimsAppService>, IDynamicClaimsAppService
{
public virtual async Task RefreshAsync()
{
await RequestAsync(nameof(RefreshAsync));
}
public virtual async Task RefreshAsync() => await RequestAsync(nameof(RefreshAsync));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
namespace Volo.Abp.Account;

public class IdentityUserDto
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,17 @@ namespace Volo.Abp.Account;
[ExposeServices(typeof(IProfileAppService), typeof(ProfileClientProxy))]
public partial class ProfileClientProxy : ClientProxyBase<IProfileAppService>, IProfileAppService
{
public virtual async Task<ProfileDto> GetAsync()
{
return await RequestAsync<ProfileDto>(nameof(GetAsync));
}
public virtual async Task<ProfileDto> GetAsync() => await RequestAsync<ProfileDto>(nameof(GetAsync));

public virtual async Task<ProfileDto> UpdateAsync(UpdateProfileDto input)
{
return await RequestAsync<ProfileDto>(nameof(UpdateAsync), new ClientProxyRequestTypeValue
public virtual async Task<ProfileDto> UpdateAsync(UpdateProfileDto input) =>
await RequestAsync<ProfileDto>(nameof(UpdateAsync), new ClientProxyRequestTypeValue
{
{ typeof(UpdateProfileDto), input }
});
}

public virtual async Task ChangePasswordAsync(ChangePasswordInput input)
{
public virtual async Task ChangePasswordAsync(ChangePasswordInput input) =>
await RequestAsync(nameof(ChangePasswordAsync), new ClientProxyRequestTypeValue
{
{ typeof(ChangePasswordInput), input }
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,19 @@ namespace Volo.Abp.Account;
typeof(AbpAspNetCoreMvcModule))]
public class AbpAccountHttpApiModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
public override void PreConfigureServices(ServiceConfigurationContext context)=>
PreConfigure<IMvcBuilder>(mvcBuilder =>
{
mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpAccountHttpApiModule).Assembly);
});
}


public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)=>
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Get<AccountResource>()
.AddBaseTypes(typeof(AbpUiResource));
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,27 @@ namespace Volo.Abp.Account;
[RemoteService(Name = AccountRemoteServiceConsts.RemoteServiceName)]
[Area(AccountRemoteServiceConsts.ModuleName)]
[Route("api/account")]
public class AccountController : AbpControllerBase, IAccountAppService
public class AccountController(IAccountAppService accountAppService) : AbpControllerBase, IAccountAppService
{
protected IAccountAppService AccountAppService { get; }

public AccountController(IAccountAppService accountAppService)
{
AccountAppService = accountAppService;
}
protected IAccountAppService AccountAppService { get; } = accountAppService;

[HttpPost]
[Route("register")]
public virtual Task<IdentityUserDto> RegisterAsync(RegisterDto input)
{
return AccountAppService.RegisterAsync(input);
}
public virtual Task<IdentityUserDto> RegisterAsync(RegisterDto input) =>
AccountAppService.RegisterAsync(input);

[HttpPost]
[Route("send-password-reset-code")]
public virtual Task SendPasswordResetCodeAsync(SendPasswordResetCodeDto input)
{
return AccountAppService.SendPasswordResetCodeAsync(input);
}
public virtual Task SendPasswordResetCodeAsync(SendPasswordResetCodeDto input) =>
AccountAppService.SendPasswordResetCodeAsync(input);

[HttpPost]
[Route("verify-password-reset-token")]
public virtual Task<bool> VerifyPasswordResetTokenAsync(VerifyPasswordResetTokenInput input)
{
return AccountAppService.VerifyPasswordResetTokenAsync(input);
}
public virtual Task<bool> VerifyPasswordResetTokenAsync(VerifyPasswordResetTokenInput input) =>
AccountAppService.VerifyPasswordResetTokenAsync(input);

[HttpPost]
[Route("reset-password")]
public virtual Task ResetPasswordAsync(ResetPasswordDto input)
{
return AccountAppService.ResetPasswordAsync(input);
}
public virtual Task ResetPasswordAsync(ResetPasswordDto input) =>
AccountAppService.ResetPasswordAsync(input);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,11 @@ namespace Volo.Abp.Account;
[Area(AccountRemoteServiceConsts.ModuleName)]
[ControllerName("DynamicClaims")]
[Route("/api/account/dynamic-claims")]
public class DynamicClaimsController : AbpControllerBase, IDynamicClaimsAppService
public class DynamicClaimsController(IDynamicClaimsAppService dynamicClaimsAppService) : AbpControllerBase, IDynamicClaimsAppService
{
protected IDynamicClaimsAppService DynamicClaimsAppService { get; }

public DynamicClaimsController(IDynamicClaimsAppService dynamicClaimsAppService)
{
DynamicClaimsAppService = dynamicClaimsAppService;
}
protected IDynamicClaimsAppService DynamicClaimsAppService { get; } = dynamicClaimsAppService;

[HttpPost]
[Route("refresh")]
public virtual Task RefreshAsync()
{
return DynamicClaimsAppService.RefreshAsync();
}
public virtual Task RefreshAsync() => DynamicClaimsAppService.RefreshAsync();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Volo.Abp.Account;

public class IdentityUserDto
{
}
Loading