Skip to content

Commit 43f749c

Browse files
committed
Go back to storing LockoutEndDateUtc as DateTime for sorting purposes if people query this directly, DateTimeOffset? doesn't serialize the same and we don't really need this type under the covers.
1 parent 4436871 commit 43f749c

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Diff for: README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,4 @@ run commands in [](build.sh)
5555
- On IdentityRole documents, create a NormalizedName field = uppercase(Name). Leave Name as is.
5656
- On IdentityUser documents, convert the values in the Roles array to uppercase
5757
- User names need to be normalized as follows
58-
- On IdentityUser documents, create a NormalizedUserName field = uppercase(UserName) and create a NormalizedEmail field = uppercase(Email). Leave UserName and Email as is.
59-
- LockoutEndDateUtc - type changed in code, but I think it is still the same in db, I have yet to verify if this requires a migration.
58+
- On IdentityUser documents, create a NormalizedUserName field = uppercase(UserName) and create a NormalizedEmail field = uppercase(Email). Leave UserName and Email as is.

Diff for: src/Microsoft.AspNetCore.Identity.MongoDB/IdentityUser.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public IdentityUser()
4343

4444
public virtual bool TwoFactorEnabled { get; set; }
4545

46-
public virtual DateTimeOffset? LockoutEndDateUtc { get; set; }
46+
public virtual DateTime? LockoutEndDateUtc { get; set; }
4747

4848
public virtual bool LockoutEnabled { get; set; }
4949

Diff for: src/Microsoft.AspNetCore.Identity.MongoDB/UserStore.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,13 @@ public virtual Task<bool> GetTwoFactorEnabledAsync(TUser user, CancellationToken
240240

241241
public virtual Task<DateTimeOffset?> GetLockoutEndDateAsync(TUser user, CancellationToken token)
242242
{
243-
return Task.FromResult(user.LockoutEndDateUtc);
243+
DateTimeOffset? dateTimeOffset = user.LockoutEndDateUtc;
244+
return Task.FromResult(dateTimeOffset);
244245
}
245246

246247
public virtual Task SetLockoutEndDateAsync(TUser user, DateTimeOffset? lockoutEnd, CancellationToken token)
247248
{
248-
user.LockoutEndDateUtc = lockoutEnd;
249+
user.LockoutEndDateUtc = lockoutEnd?.UtcDateTime;
249250
return Task.FromResult(0);
250251
}
251252

Diff for: src/Microsoft.AspNetCore.Identity.MongoDB/project.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Microsoft.AspNetCore.Identity.MongoDB",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44

55
"description":
66
"A MongoDB provider for ASP.NET Core Identity framework.",
@@ -14,7 +14,7 @@
1414
"packOptions": {
1515
"summary": "A MongoDB provider for ASP.NET Core Identity",
1616
"owners": ["Wes Higbee"],
17-
"releaseNotes": "Port of AspNet.Identity.MongoDB to ASP.NET Core",
17+
"releaseNotes": "Convert back to using DateTime to store LockoutEndDate, DateTimeOffset serializes to an array of values which could make it hard for people to sort on this and query on this. Also DateTime was used in the v2 driver, so this makes the upgrade story easier.",
1818

1919
"tags": [
2020
"aspnetcore",

0 commit comments

Comments
 (0)