diff options
| author | Claus Vium <clausvium@gmail.com> | 2019-03-07 20:16:51 +0100 |
|---|---|---|
| committer | Claus Vium <clausvium@gmail.com> | 2019-03-07 20:16:51 +0100 |
| commit | 0abe57e930e44eab9566991f33b089d1e61cfb83 (patch) | |
| tree | 602be322daedca127ba66de07837ac8e792730a7 /Emby.Server.Implementations/Data/SqliteUserRepository.cs | |
| parent | dfff68b2f4ca8d3da59508eb4cbe2e751ed76f49 (diff) | |
| parent | ae0ecc1b10982d9240ecdcc82cb7299fc708aafb (diff) | |
Merge remote-tracking branch 'remotes/upstream/master' into kestrel_poc
Diffstat (limited to 'Emby.Server.Implementations/Data/SqliteUserRepository.cs')
| -rw-r--r-- | Emby.Server.Implementations/Data/SqliteUserRepository.cs | 34 |
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> |
