diff --git a/Libraries/SPTarkov.Server.Core/Migration/Migrations/4.0/RemovePassword.cs b/Libraries/SPTarkov.Server.Core/Migration/Migrations/4.0/RemovePassword.cs new file mode 100644 index 00000000..061056ae --- /dev/null +++ b/Libraries/SPTarkov.Server.Core/Migration/Migrations/4.0/RemovePassword.cs @@ -0,0 +1,46 @@ +using System.Text.Json.Nodes; +using SPTarkov.DI.Annotations; + +namespace SPTarkov.Server.Core.Migration.Migrations; + +/// +/// Password property was removed from profile.info in 4.0 +/// +[Injectable] +public class RemovePassword : AbstractProfileMigration +{ + public override string FromVersion + { + get { return "~3.11"; } + } + + public override string ToVersion + { + get { return "4.0"; } + } + + public override string MigrationName + { + get { return "RemovePassword-SPTSharp"; } + } + + public override IEnumerable PrerequisiteMigrations + { + get { return []; } + } + + public override bool CanMigrate(JsonObject profile, IEnumerable previouslyRanMigrations) + { + var hasPassword = profile["info"]?["password"] != null; + + return hasPassword; + } + + public override JsonObject? Migrate(JsonObject profile) + { + var profileInfo = profile["info"] as JsonObject; + profileInfo?.Remove("password"); + + return base.Migrate(profile); + } +}