Browse Source

Change DateTime to DateTimeOffset

pull/15956/head
liangshiwei 4 years ago
parent
commit
6a638f9661
  1. 6
      modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSignInManager.cs
  2. 4
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs
  3. 10
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs
  4. 5
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserStore.cs
  5. 6
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpResourceOwnerPasswordValidator.cs
  6. 2
      templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.Server/Migrations/20230314024329_Initial.cs
  7. 2
      templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server/Migrations/20230314024404_Initial.cs
  8. 2
      templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host/Migrations/20230314024402_Initial.cs
  9. 2
      templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Mvc/Migrations/20230314024433_Initial.cs
  10. 2
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20230314023936_Initial.cs
  11. 2
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.AuthServer/Migrations/20230314024642_Initial.cs
  12. 2
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Migrations/20230314024129_Initial.cs
  13. 2
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20230314024104_Initial.cs

6
modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSignInManager.cs

@ -17,8 +17,6 @@ public class AbpSignInManager : SignInManager<IdentityUser>
protected ISettingProvider SettingProvider { get; }
protected IClock Clock { get; }
private readonly IdentityUserManager _identityUserManager;
public AbpSignInManager(
@ -30,8 +28,7 @@ public class AbpSignInManager : SignInManager<IdentityUser>
IAuthenticationSchemeProvider schemes,
IUserConfirmation<IdentityUser> confirmation,
IOptions<AbpIdentityOptions> options,
ISettingProvider settingProvider,
IClock clock) : base(
ISettingProvider settingProvider) : base(
userManager,
contextAccessor,
claimsFactory,
@ -41,7 +38,6 @@ public class AbpSignInManager : SignInManager<IdentityUser>
confirmation)
{
SettingProvider = settingProvider;
Clock = clock;
AbpOptions = options.Value;
_identityUserManager = userManager;
}

4
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs

@ -125,7 +125,7 @@ public class IdentityUser : FullAuditedAggregateRoot<Guid>, IUser, IHasEntityVer
/// <summary>
/// Gets or sets the last password change time for the user.
/// </summary>
public virtual DateTime? LastPasswordChangeTime { get; protected set; }
public virtual DateTimeOffset? LastPasswordChangeTime { get; protected set; }
//TODO: Can we make collections readonly collection, which will provide encapsulation. But... can work for all ORMs?
@ -383,7 +383,7 @@ public class IdentityUser : FullAuditedAggregateRoot<Guid>, IUser, IHasEntityVer
ShouldChangePasswordOnNextLogin = shouldChangePasswordOnNextLogin;
}
public virtual void SetLastPasswordChangeTime(DateTime? lastPasswordChangeTime)
public virtual void SetLastPasswordChangeTime(DateTimeOffset? lastPasswordChangeTime)
{
LastPasswordChangeTime = lastPasswordChangeTime;
}

10
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs

@ -26,8 +26,6 @@ public class IdentityUserManager : UserManager<IdentityUser>, IDomainService
protected ISettingProvider SettingProvider { get; }
protected ICancellationTokenProvider CancellationTokenProvider { get; }
protected IClock Clock { get; }
protected override CancellationToken CancellationToken => CancellationTokenProvider.Token;
public IdentityUserManager(
@ -44,8 +42,7 @@ public class IdentityUserManager : UserManager<IdentityUser>, IDomainService
ILogger<IdentityUserManager> logger,
ICancellationTokenProvider cancellationTokenProvider,
IOrganizationUnitRepository organizationUnitRepository,
ISettingProvider settingProvider,
IClock clock)
ISettingProvider settingProvider)
: base(
store,
optionsAccessor,
@ -59,7 +56,6 @@ public class IdentityUserManager : UserManager<IdentityUser>, IDomainService
{
OrganizationUnitRepository = organizationUnitRepository;
SettingProvider = settingProvider;
Clock = clock;
RoleRepository = roleRepository;
UserRepository = userRepository;
CancellationTokenProvider = cancellationTokenProvider;
@ -274,9 +270,9 @@ public class IdentityUserManager : UserManager<IdentityUser>, IDomainService
return false;
}
var lastPasswordChangeTime = user.LastPasswordChangeTime ?? user.CreationTime;
var lastPasswordChangeTime = user.LastPasswordChangeTime ?? DateTime.SpecifyKind(user.CreationTime, DateTimeKind.Utc);
var passwordChangePeriodDays = await SettingProvider.GetAsync<int>(IdentitySettingNames.Password.PasswordChangePeriodDays);
return passwordChangePeriodDays > 0 && lastPasswordChangeTime.AddDays(passwordChangePeriodDays) < Clock.Now;
return passwordChangePeriodDays > 0 && lastPasswordChangeTime.AddDays(passwordChangePeriodDays) < DateTime.UtcNow;
}
}

5
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserStore.cs

@ -56,7 +56,6 @@ public class IdentityUserStore :
protected ILogger<IdentityRoleStore> Logger { get; }
protected ILookupNormalizer LookupNormalizer { get; }
protected IIdentityUserRepository UserRepository { get; }
protected IClock Clock { get; }
public IdentityUserStore(
IIdentityUserRepository userRepository,
@ -64,7 +63,6 @@ public class IdentityUserStore :
IGuidGenerator guidGenerator,
ILogger<IdentityRoleStore> logger,
ILookupNormalizer lookupNormalizer,
IClock clock,
IdentityErrorDescriber describer = null)
{
UserRepository = userRepository;
@ -72,7 +70,6 @@ public class IdentityUserStore :
GuidGenerator = guidGenerator;
Logger = logger;
LookupNormalizer = lookupNormalizer;
Clock = clock;
ErrorDescriber = describer ?? new IdentityErrorDescriber();
}
@ -274,7 +271,7 @@ public class IdentityUserStore :
if (await FindByIdAsync(user.Id.ToString(), cancellationToken) != null)
{
user.SetLastPasswordChangeTime(Clock.Now);
user.SetLastPasswordChangeTime(DateTime.UtcNow);
}
}

6
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpResourceOwnerPasswordValidator.cs

@ -41,8 +41,6 @@ public class AbpResourceOwnerPasswordValidator : IResourceOwnerPasswordValidator
protected ISettingProvider SettingProvider { get; }
protected IClock Clock { get; }
public AbpResourceOwnerPasswordValidator(
IdentityUserManager userManager,
SignInManager<IdentityUser> signInManager,
@ -52,8 +50,7 @@ public class AbpResourceOwnerPasswordValidator : IResourceOwnerPasswordValidator
IOptions<AbpIdentityOptions> abpIdentityOptions,
IServiceScopeFactory serviceScopeFactory,
IOptions<IdentityOptions> identityOptions,
ISettingProvider settingProvider,
IClock clock)
ISettingProvider settingProvider)
{
UserManager = userManager;
SignInManager = signInManager;
@ -64,7 +61,6 @@ public class AbpResourceOwnerPasswordValidator : IResourceOwnerPasswordValidator
AbpIdentityOptions = abpIdentityOptions.Value;
IdentityOptions = identityOptions;
SettingProvider = settingProvider;
Clock = clock;
}
/// <summary>

2
templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.Server/Migrations/20230314024329_Initial.cs

@ -317,7 +317,7 @@ namespace MyCompanyName.MyProjectName.Blazor.Server.Migrations
AccessFailedCount = table.Column<int>(type: "int", nullable: false, defaultValue: 0),
ShouldChangePasswordOnNextLogin = table.Column<bool>(type: "bit", nullable: false),
EntityVersion = table.Column<int>(type: "int", nullable: false),
LastPasswordChangeTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastPasswordChangeTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),

2
templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server/Migrations/20230314024404_Initial.cs

@ -317,7 +317,7 @@ namespace MyCompanyName.MyProjectName.Migrations
AccessFailedCount = table.Column<int>(type: "int", nullable: false, defaultValue: 0),
ShouldChangePasswordOnNextLogin = table.Column<bool>(type: "bit", nullable: false),
EntityVersion = table.Column<int>(type: "int", nullable: false),
LastPasswordChangeTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastPasswordChangeTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),

2
templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host/Migrations/20230314024402_Initial.cs

@ -317,7 +317,7 @@ namespace MyCompanyName.MyProjectName.Host.Migrations
AccessFailedCount = table.Column<int>(type: "int", nullable: false, defaultValue: 0),
ShouldChangePasswordOnNextLogin = table.Column<bool>(type: "bit", nullable: false),
EntityVersion = table.Column<int>(type: "int", nullable: false),
LastPasswordChangeTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastPasswordChangeTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),

2
templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Mvc/Migrations/20230314024433_Initial.cs

@ -317,7 +317,7 @@ namespace MyCompanyName.MyProjectName.Mvc.Migrations
AccessFailedCount = table.Column<int>(type: "int", nullable: false, defaultValue: 0),
ShouldChangePasswordOnNextLogin = table.Column<bool>(type: "bit", nullable: false),
EntityVersion = table.Column<int>(type: "int", nullable: false),
LastPasswordChangeTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastPasswordChangeTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),

2
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20230314023936_Initial.cs

@ -338,7 +338,7 @@ namespace MyCompanyName.MyProjectName.Migrations
AccessFailedCount = table.Column<int>(type: "int", nullable: false, defaultValue: 0),
ShouldChangePasswordOnNextLogin = table.Column<bool>(type: "bit", nullable: false),
EntityVersion = table.Column<int>(type: "int", nullable: false),
LastPasswordChangeTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastPasswordChangeTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),

2
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.AuthServer/Migrations/20230314024642_Initial.cs

@ -317,7 +317,7 @@ namespace MyCompanyName.MyProjectName.Migrations
AccessFailedCount = table.Column<int>(type: "int", nullable: false, defaultValue: 0),
ShouldChangePasswordOnNextLogin = table.Column<bool>(type: "bit", nullable: false),
EntityVersion = table.Column<int>(type: "int", nullable: false),
LastPasswordChangeTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastPasswordChangeTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),

2
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Migrations/20230314024129_Initial.cs

@ -317,7 +317,7 @@ namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Migrations
AccessFailedCount = table.Column<int>(type: "int", nullable: false, defaultValue: 0),
ShouldChangePasswordOnNextLogin = table.Column<bool>(type: "bit", nullable: false),
EntityVersion = table.Column<int>(type: "int", nullable: false),
LastPasswordChangeTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastPasswordChangeTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),

2
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20230314024104_Initial.cs

@ -317,7 +317,7 @@ namespace MyCompanyName.MyProjectName.Migrations
AccessFailedCount = table.Column<int>(type: "int", nullable: false, defaultValue: 0),
ShouldChangePasswordOnNextLogin = table.Column<bool>(type: "bit", nullable: false),
EntityVersion = table.Column<int>(type: "int", nullable: false),
LastPasswordChangeTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastPasswordChangeTime = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),

Loading…
Cancel
Save