aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Data/SqliteUserRepository.cs
diff options
context:
space:
mode:
authorredSpoutnik <15638041+redSpoutnik@users.noreply.github.com>2019-03-16 17:54:57 +0100
committerGitHub <noreply@github.com>2019-03-16 17:54:57 +0100
commit480a6607e2badad925216e715841cce6300ef98e (patch)
tree01e09eb894f973f4519342dc6df502e3f1f2799f /Emby.Server.Implementations/Data/SqliteUserRepository.cs
parent4a30fee40df69be381c2cdea01cd4dd29b97ad3c (diff)
parent3d1d27230de88cbf5c3ed3f882399175661c1c94 (diff)
Merge branch 'master' into subtitle-display-title
Diffstat (limited to 'Emby.Server.Implementations/Data/SqliteUserRepository.cs')
-rw-r--r--Emby.Server.Implementations/Data/SqliteUserRepository.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteUserRepository.cs b/Emby.Server.Implementations/Data/SqliteUserRepository.cs
index db359d7dd..182df0edc 100644
--- a/Emby.Server.Implementations/Data/SqliteUserRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteUserRepository.cs
@@ -55,6 +55,8 @@ namespace Emby.Server.Implementations.Data
{
TryMigrateToLocalUsersTable(connection);
}
+
+ RemoveEmptyPasswordHashes();
}
}
@@ -73,6 +75,38 @@ namespace Emby.Server.Implementations.Data
}
}
+ private void RemoveEmptyPasswordHashes()
+ {
+ foreach (var user in RetrieveAllUsers())
+ {
+ // If the user password is the sha1 hash of the empty string, remove it
+ if (!string.Equals(user.Password, "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709", StringComparison.Ordinal)
+ || !string.Equals(user.Password, "$SHA1$DA39A3EE5E6B4B0D3255BFEF95601890AFD80709", StringComparison.Ordinal))
+ {
+ continue;
+ }
+
+ user.Password = null;
+ var serialized = _jsonSerializer.SerializeToBytes(user);
+
+ using (WriteLock.Write())
+ using (var connection = CreateConnection())
+ {
+ connection.RunInTransaction(db =>
+ {
+ using (var statement = db.PrepareStatement("update LocalUsersv2 set data=@data where Id=@InternalId"))
+ {
+ statement.TryBind("@InternalId", user.InternalId);
+ statement.TryBind("@data", serialized);
+ statement.MoveNext();
+ }
+
+ }, TransactionMode);
+ }
+ }
+
+ }
+
/// <summary>
/// Save a user in the repo
/// </summary>