Skip to content

Commit 3e23d22

Browse files
authored
Merge pull request #674 from aspnetboilerplate/upgrade-to-abp-10.0-and-dotnet-9
Upgrade to ABP 10.0 and .NET 9
2 parents 17d03f1 + 2eb26d7 commit 3e23d22

File tree

204 files changed

+6631
-6873
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

204 files changed

+6631
-6873
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
43
<VersionPrefix>1.0.0.0</VersionPrefix>
5-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
65
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
76
<AssemblyName>AbpCompanyName.AbpProjectName.Application</AssemblyName>
87
<PackageId>AbpCompanyName.AbpProjectName.Application</PackageId>
@@ -12,9 +11,7 @@
1211
<RootNamespace>AbpCompanyName.AbpProjectName</RootNamespace>
1312
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1413
</PropertyGroup>
15-
1614
<ItemGroup>
1715
<ProjectReference Include="..\AbpCompanyName.AbpProjectName.Core\AbpCompanyName.AbpProjectName.Core.csproj" />
1816
</ItemGroup>
19-
20-
</Project>
17+
</Project>
Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,46 @@
1-
using System;
2-
using System.Threading.Tasks;
3-
using Microsoft.AspNetCore.Identity;
4-
using Abp.Application.Services;
1+
using Abp.Application.Services;
52
using Abp.IdentityFramework;
63
using Abp.Runtime.Session;
74
using AbpCompanyName.AbpProjectName.Authorization.Users;
85
using AbpCompanyName.AbpProjectName.MultiTenancy;
6+
using Microsoft.AspNetCore.Identity;
7+
using System;
8+
using System.Threading.Tasks;
9+
10+
namespace AbpCompanyName.AbpProjectName;
911

10-
namespace AbpCompanyName.AbpProjectName
12+
/// <summary>
13+
/// Derive your application services from this class.
14+
/// </summary>
15+
public abstract class AbpProjectNameAppServiceBase : ApplicationService
1116
{
12-
/// <summary>
13-
/// Derive your application services from this class.
14-
/// </summary>
15-
public abstract class AbpProjectNameAppServiceBase : ApplicationService
16-
{
17-
public TenantManager TenantManager { get; set; }
17+
public TenantManager TenantManager { get; set; }
1818

19-
public UserManager UserManager { get; set; }
19+
public UserManager UserManager { get; set; }
2020

21-
protected AbpProjectNameAppServiceBase()
22-
{
23-
LocalizationSourceName = AbpProjectNameConsts.LocalizationSourceName;
24-
}
21+
protected AbpProjectNameAppServiceBase()
22+
{
23+
LocalizationSourceName = AbpProjectNameConsts.LocalizationSourceName;
24+
}
2525

26-
protected virtual async Task<User> GetCurrentUserAsync()
26+
protected virtual async Task<User> GetCurrentUserAsync()
27+
{
28+
var user = await UserManager.FindByIdAsync(AbpSession.GetUserId().ToString());
29+
if (user == null)
2730
{
28-
var user = await UserManager.FindByIdAsync(AbpSession.GetUserId().ToString());
29-
if (user == null)
30-
{
31-
throw new Exception("There is no current user!");
32-
}
33-
34-
return user;
31+
throw new Exception("There is no current user!");
3532
}
3633

37-
protected virtual Task<Tenant> GetCurrentTenantAsync()
38-
{
39-
return TenantManager.GetByIdAsync(AbpSession.GetTenantId());
40-
}
34+
return user;
35+
}
4136

42-
protected virtual void CheckErrors(IdentityResult identityResult)
43-
{
44-
identityResult.CheckErrors(LocalizationManager);
45-
}
37+
protected virtual Task<Tenant> GetCurrentTenantAsync()
38+
{
39+
return TenantManager.GetByIdAsync(AbpSession.GetTenantId());
40+
}
41+
42+
protected virtual void CheckErrors(IdentityResult identityResult)
43+
{
44+
identityResult.CheckErrors(LocalizationManager);
4645
}
4746
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/AbpProjectNameApplicationModule.cs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,27 @@
33
using Abp.Reflection.Extensions;
44
using AbpCompanyName.AbpProjectName.Authorization;
55

6-
namespace AbpCompanyName.AbpProjectName
6+
namespace AbpCompanyName.AbpProjectName;
7+
8+
[DependsOn(
9+
typeof(AbpProjectNameCoreModule),
10+
typeof(AbpAutoMapperModule))]
11+
public class AbpProjectNameApplicationModule : AbpModule
712
{
8-
[DependsOn(
9-
typeof(AbpProjectNameCoreModule),
10-
typeof(AbpAutoMapperModule))]
11-
public class AbpProjectNameApplicationModule : AbpModule
13+
public override void PreInitialize()
1214
{
13-
public override void PreInitialize()
14-
{
15-
Configuration.Authorization.Providers.Add<AbpProjectNameAuthorizationProvider>();
16-
}
15+
Configuration.Authorization.Providers.Add<AbpProjectNameAuthorizationProvider>();
16+
}
1717

18-
public override void Initialize()
19-
{
20-
var thisAssembly = typeof(AbpProjectNameApplicationModule).GetAssembly();
18+
public override void Initialize()
19+
{
20+
var thisAssembly = typeof(AbpProjectNameApplicationModule).GetAssembly();
2121

22-
IocManager.RegisterAssemblyByConvention(thisAssembly);
22+
IocManager.RegisterAssemblyByConvention(thisAssembly);
2323

24-
Configuration.Modules.AbpAutoMapper().Configurators.Add(
25-
// Scan the assembly for classes which inherit from AutoMapper.Profile
26-
cfg => cfg.AddMaps(thisAssembly)
27-
);
28-
}
24+
Configuration.Modules.AbpAutoMapper().Configurators.Add(
25+
// Scan the assembly for classes which inherit from AutoMapper.Profile
26+
cfg => cfg.AddMaps(thisAssembly)
27+
);
2928
}
3029
}
Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,63 @@
1-
using System;
2-
using Abp;
1+
using Abp;
32
using Abp.Authorization;
43
using Abp.Dependency;
54
using Abp.UI;
5+
using System;
66

7-
namespace AbpCompanyName.AbpProjectName.Authorization
7+
namespace AbpCompanyName.AbpProjectName.Authorization;
8+
9+
public class AbpLoginResultTypeHelper : AbpServiceBase, ITransientDependency
810
{
9-
public class AbpLoginResultTypeHelper : AbpServiceBase, ITransientDependency
11+
public AbpLoginResultTypeHelper()
1012
{
11-
public AbpLoginResultTypeHelper()
12-
{
13-
LocalizationSourceName = AbpProjectNameConsts.LocalizationSourceName;
14-
}
13+
LocalizationSourceName = AbpProjectNameConsts.LocalizationSourceName;
14+
}
1515

16-
public Exception CreateExceptionForFailedLoginAttempt(AbpLoginResultType result, string usernameOrEmailAddress, string tenancyName)
16+
public Exception CreateExceptionForFailedLoginAttempt(AbpLoginResultType result, string usernameOrEmailAddress, string tenancyName)
17+
{
18+
switch (result)
1719
{
18-
switch (result)
19-
{
20-
case AbpLoginResultType.Success:
21-
return new Exception("Don't call this method with a success result!");
22-
case AbpLoginResultType.InvalidUserNameOrEmailAddress:
23-
case AbpLoginResultType.InvalidPassword:
24-
return new UserFriendlyException(L("LoginFailed"), L("InvalidUserNameOrPassword"));
25-
case AbpLoginResultType.InvalidTenancyName:
26-
return new UserFriendlyException(L("LoginFailed"), L("ThereIsNoTenantDefinedWithName{0}", tenancyName));
27-
case AbpLoginResultType.TenantIsNotActive:
28-
return new UserFriendlyException(L("LoginFailed"), L("TenantIsNotActive", tenancyName));
29-
case AbpLoginResultType.UserIsNotActive:
30-
return new UserFriendlyException(L("LoginFailed"), L("UserIsNotActiveAndCanNotLogin", usernameOrEmailAddress));
31-
case AbpLoginResultType.UserEmailIsNotConfirmed:
32-
return new UserFriendlyException(L("LoginFailed"), L("UserEmailIsNotConfirmedAndCanNotLogin"));
33-
case AbpLoginResultType.LockedOut:
34-
return new UserFriendlyException(L("LoginFailed"), L("UserLockedOutMessage"));
35-
default: // Can not fall to default actually. But other result types can be added in the future and we may forget to handle it
36-
Logger.Warn("Unhandled login fail reason: " + result);
37-
return new UserFriendlyException(L("LoginFailed"));
38-
}
20+
case AbpLoginResultType.Success:
21+
return new Exception("Don't call this method with a success result!");
22+
case AbpLoginResultType.InvalidUserNameOrEmailAddress:
23+
case AbpLoginResultType.InvalidPassword:
24+
return new UserFriendlyException(L("LoginFailed"), L("InvalidUserNameOrPassword"));
25+
case AbpLoginResultType.InvalidTenancyName:
26+
return new UserFriendlyException(L("LoginFailed"), L("ThereIsNoTenantDefinedWithName{0}", tenancyName));
27+
case AbpLoginResultType.TenantIsNotActive:
28+
return new UserFriendlyException(L("LoginFailed"), L("TenantIsNotActive", tenancyName));
29+
case AbpLoginResultType.UserIsNotActive:
30+
return new UserFriendlyException(L("LoginFailed"), L("UserIsNotActiveAndCanNotLogin", usernameOrEmailAddress));
31+
case AbpLoginResultType.UserEmailIsNotConfirmed:
32+
return new UserFriendlyException(L("LoginFailed"), L("UserEmailIsNotConfirmedAndCanNotLogin"));
33+
case AbpLoginResultType.LockedOut:
34+
return new UserFriendlyException(L("LoginFailed"), L("UserLockedOutMessage"));
35+
default: // Can not fall to default actually. But other result types can be added in the future and we may forget to handle it
36+
Logger.Warn("Unhandled login fail reason: " + result);
37+
return new UserFriendlyException(L("LoginFailed"));
3938
}
39+
}
4040

41-
public string CreateLocalizedMessageForFailedLoginAttempt(AbpLoginResultType result, string usernameOrEmailAddress, string tenancyName)
41+
public string CreateLocalizedMessageForFailedLoginAttempt(AbpLoginResultType result, string usernameOrEmailAddress, string tenancyName)
42+
{
43+
switch (result)
4244
{
43-
switch (result)
44-
{
45-
case AbpLoginResultType.Success:
46-
throw new Exception("Don't call this method with a success result!");
47-
case AbpLoginResultType.InvalidUserNameOrEmailAddress:
48-
case AbpLoginResultType.InvalidPassword:
49-
return L("InvalidUserNameOrPassword");
50-
case AbpLoginResultType.InvalidTenancyName:
51-
return L("ThereIsNoTenantDefinedWithName{0}", tenancyName);
52-
case AbpLoginResultType.TenantIsNotActive:
53-
return L("TenantIsNotActive", tenancyName);
54-
case AbpLoginResultType.UserIsNotActive:
55-
return L("UserIsNotActiveAndCanNotLogin", usernameOrEmailAddress);
56-
case AbpLoginResultType.UserEmailIsNotConfirmed:
57-
return L("UserEmailIsNotConfirmedAndCanNotLogin");
58-
default: // Can not fall to default actually. But other result types can be added in the future and we may forget to handle it
59-
Logger.Warn("Unhandled login fail reason: " + result);
60-
return L("LoginFailed");
61-
}
45+
case AbpLoginResultType.Success:
46+
throw new Exception("Don't call this method with a success result!");
47+
case AbpLoginResultType.InvalidUserNameOrEmailAddress:
48+
case AbpLoginResultType.InvalidPassword:
49+
return L("InvalidUserNameOrPassword");
50+
case AbpLoginResultType.InvalidTenancyName:
51+
return L("ThereIsNoTenantDefinedWithName{0}", tenancyName);
52+
case AbpLoginResultType.TenantIsNotActive:
53+
return L("TenantIsNotActive", tenancyName);
54+
case AbpLoginResultType.UserIsNotActive:
55+
return L("UserIsNotActiveAndCanNotLogin", usernameOrEmailAddress);
56+
case AbpLoginResultType.UserEmailIsNotConfirmed:
57+
return L("UserEmailIsNotConfirmedAndCanNotLogin");
58+
default: // Can not fall to default actually. But other result types can be added in the future and we may forget to handle it
59+
Logger.Warn("Unhandled login fail reason: " + result);
60+
return L("LoginFailed");
6261
}
6362
}
6463
}
Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,56 @@
1-
using System.Threading.Tasks;
21
using Abp.Configuration;
32
using Abp.Zero.Configuration;
43
using AbpCompanyName.AbpProjectName.Authorization.Accounts.Dto;
54
using AbpCompanyName.AbpProjectName.Authorization.Users;
5+
using System.Threading.Tasks;
6+
7+
namespace AbpCompanyName.AbpProjectName.Authorization.Accounts;
68

7-
namespace AbpCompanyName.AbpProjectName.Authorization.Accounts
9+
public class AccountAppService : AbpProjectNameAppServiceBase, IAccountAppService
810
{
9-
public class AccountAppService : AbpProjectNameAppServiceBase, IAccountAppService
10-
{
11-
// from: http://regexlib.com/REDetails.aspx?regexp_id=1923
12-
public const string PasswordRegex = "(?=^.{8,}$)(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\\s)[0-9a-zA-Z!@#$%^&*()]*$";
11+
// from: http://regexlib.com/REDetails.aspx?regexp_id=1923
12+
public const string PasswordRegex = "(?=^.{8,}$)(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\\s)[0-9a-zA-Z!@#$%^&*()]*$";
13+
14+
private readonly UserRegistrationManager _userRegistrationManager;
1315

14-
private readonly UserRegistrationManager _userRegistrationManager;
16+
public AccountAppService(
17+
UserRegistrationManager userRegistrationManager)
18+
{
19+
_userRegistrationManager = userRegistrationManager;
20+
}
1521

16-
public AccountAppService(
17-
UserRegistrationManager userRegistrationManager)
22+
public async Task<IsTenantAvailableOutput> IsTenantAvailable(IsTenantAvailableInput input)
23+
{
24+
var tenant = await TenantManager.FindByTenancyNameAsync(input.TenancyName);
25+
if (tenant == null)
1826
{
19-
_userRegistrationManager = userRegistrationManager;
27+
return new IsTenantAvailableOutput(TenantAvailabilityState.NotFound);
2028
}
2129

22-
public async Task<IsTenantAvailableOutput> IsTenantAvailable(IsTenantAvailableInput input)
30+
if (!tenant.IsActive)
2331
{
24-
var tenant = await TenantManager.FindByTenancyNameAsync(input.TenancyName);
25-
if (tenant == null)
26-
{
27-
return new IsTenantAvailableOutput(TenantAvailabilityState.NotFound);
28-
}
29-
30-
if (!tenant.IsActive)
31-
{
32-
return new IsTenantAvailableOutput(TenantAvailabilityState.InActive);
33-
}
34-
35-
return new IsTenantAvailableOutput(TenantAvailabilityState.Available, tenant.Id);
32+
return new IsTenantAvailableOutput(TenantAvailabilityState.InActive);
3633
}
3734

38-
public async Task<RegisterOutput> Register(RegisterInput input)
35+
return new IsTenantAvailableOutput(TenantAvailabilityState.Available, tenant.Id);
36+
}
37+
38+
public async Task<RegisterOutput> Register(RegisterInput input)
39+
{
40+
var user = await _userRegistrationManager.RegisterAsync(
41+
input.Name,
42+
input.Surname,
43+
input.EmailAddress,
44+
input.UserName,
45+
input.Password,
46+
true // Assumed email address is always confirmed. Change this if you want to implement email confirmation.
47+
);
48+
49+
var isEmailConfirmationRequiredForLogin = await SettingManager.GetSettingValueAsync<bool>(AbpZeroSettingNames.UserManagement.IsEmailConfirmationRequiredForLogin);
50+
51+
return new RegisterOutput
3952
{
40-
var user = await _userRegistrationManager.RegisterAsync(
41-
input.Name,
42-
input.Surname,
43-
input.EmailAddress,
44-
input.UserName,
45-
input.Password,
46-
true // Assumed email address is always confirmed. Change this if you want to implement email confirmation.
47-
);
48-
49-
var isEmailConfirmationRequiredForLogin = await SettingManager.GetSettingValueAsync<bool>(AbpZeroSettingNames.UserManagement.IsEmailConfirmationRequiredForLogin);
50-
51-
return new RegisterOutput
52-
{
53-
CanLogin = user.IsActive && (user.IsEmailConfirmed || !isEmailConfirmationRequiredForLogin)
54-
};
55-
}
53+
CanLogin = user.IsActive && (user.IsEmailConfirmed || !isEmailConfirmationRequiredForLogin)
54+
};
5655
}
5756
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
using System.ComponentModel.DataAnnotations;
2-
using Abp.MultiTenancy;
1+
using Abp.MultiTenancy;
2+
using System.ComponentModel.DataAnnotations;
33

4-
namespace AbpCompanyName.AbpProjectName.Authorization.Accounts.Dto
4+
namespace AbpCompanyName.AbpProjectName.Authorization.Accounts.Dto;
5+
6+
public class IsTenantAvailableInput
57
{
6-
public class IsTenantAvailableInput
7-
{
8-
[Required]
9-
[StringLength(AbpTenantBase.MaxTenancyNameLength)]
10-
public string TenancyName { get; set; }
11-
}
8+
[Required]
9+
[StringLength(AbpTenantBase.MaxTenancyNameLength)]
10+
public string TenancyName { get; set; }
1211
}

0 commit comments

Comments
 (0)