diff --git a/src/AspNetCore.Identity.Mongo/AspNetCore.Identity.Mongo.csproj b/src/AspNetCore.Identity.Mongo/AspNetCore.Identity.Mongo.csproj
index 3086ef7..71ef256 100644
--- a/src/AspNetCore.Identity.Mongo/AspNetCore.Identity.Mongo.csproj
+++ b/src/AspNetCore.Identity.Mongo/AspNetCore.Identity.Mongo.csproj
@@ -14,12 +14,12 @@
Matteo Fabbri
AspNetCore.Identity.Mongo
- 8.3.1
- 8.3.1.0
- 8.3.1.0
+ 8.3.2
+ 8.3.2.0
+ 8.3.2.0
https://github.com/matteofabbri/AspNetCore.Identity.Mongo
- Fixed recovery codes not being removed after use.
+ Removed obsolete properties.
false
false
LICENSE.txt
diff --git a/src/AspNetCore.Identity.Mongo/Migrations/Migrator.cs b/src/AspNetCore.Identity.Mongo/Migrations/Migrator.cs
index 64ce6f2..b47b588 100644
--- a/src/AspNetCore.Identity.Mongo/Migrations/Migrator.cs
+++ b/src/AspNetCore.Identity.Mongo/Migrations/Migrator.cs
@@ -11,7 +11,7 @@ namespace AspNetCore.Identity.Mongo.Migrations
internal static class Migrator
{
//Starting from 4 in case we want to implement migrations for previous versions
- public static int CurrentVersion = 5;
+ public static int CurrentVersion = 6;
public static void Apply(IMongoCollection migrationCollection, IMongoCollection usersCollection, IMongoCollection rolesCollection)
where TKey : IEquatable
@@ -30,20 +30,31 @@ internal static class Migrator
}
// 4 -> 5
- var users = usersCollection.Find(x => !string.IsNullOrEmpty(x.AuthenticatorKey)).ToList();
- foreach (var user in users)
+ if (lastHistory.DatabaseVersion == 4)
{
- var tokens = user.Tokens;
- tokens.Add(new Microsoft.AspNetCore.Identity.IdentityUserToken()
+ var users = usersCollection.Find(x => !string.IsNullOrEmpty(x.AuthenticatorKey)).ToList();
+ foreach (var user in users)
{
- UserId = user.Id.ToString(),
- Value = user.AuthenticatorKey,
- LoginProvider = "[AspNetUserStore]",
- Name = "AuthenticatorKey"
- });
- usersCollection.UpdateOne(x => x.Id.Equals(user.Id),
- Builders.Update.Set(x => x.Tokens, tokens)
- .Set(x => x.AuthenticatorKey, null));
+ var tokens = user.Tokens;
+ tokens.Add(new Microsoft.AspNetCore.Identity.IdentityUserToken()
+ {
+ UserId = user.Id.ToString(),
+ Value = user.AuthenticatorKey,
+ LoginProvider = "[AspNetUserStore]",
+ Name = "AuthenticatorKey"
+ });
+ usersCollection.UpdateOne(x => x.Id.Equals(user.Id),
+ Builders.Update.Set(x => x.Tokens, tokens)
+ .Set(x => x.AuthenticatorKey, null));
+ }
+ }
+
+ // 5 -> 6
+ if (lastHistory.DatabaseVersion == 5)
+ {
+ usersCollection.UpdateMany(x => true,
+ Builders.Update.Unset(x => x.AuthenticatorKey)
+ .Unset(x => x.RecoveryCodes));
}
}