aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Data/SqliteUserRepository.cs
diff options
context:
space:
mode:
authorBond_009 <Bond.009@outlook.com>2019-04-03 18:15:04 +0200
committerBond_009 <bond.009@outlook.com>2019-06-28 12:14:27 +0200
commitd961278b3dcab57910b260115cd45d9831e6443e (patch)
tree1628aa5bed980824b4bba1b6bc9890c035413ef7 /Emby.Server.Implementations/Data/SqliteUserRepository.cs
parentdb2765aae5556fd4e05e1c310027bdbd699327d2 (diff)
Reduce amount of raw sql
Diffstat (limited to 'Emby.Server.Implementations/Data/SqliteUserRepository.cs')
-rw-r--r--Emby.Server.Implementations/Data/SqliteUserRepository.cs23
1 files changed, 13 insertions, 10 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteUserRepository.cs b/Emby.Server.Implementations/Data/SqliteUserRepository.cs
index cd364e7f4..de2354eef 100644
--- a/Emby.Server.Implementations/Data/SqliteUserRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteUserRepository.cs
@@ -75,10 +75,8 @@ namespace Emby.Server.Implementations.Data
private void RemoveEmptyPasswordHashes(ManagedConnection connection)
{
- foreach (var row in connection.Query("select id,guid,data from LocalUsersv2"))
+ foreach (var user in RetrieveAllUsers(connection))
{
- var user = GetUser(row);
-
// 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))
@@ -198,17 +196,22 @@ namespace Emby.Server.Implementations.Data
/// <returns>IEnumerable{User}.</returns>
public List<User> RetrieveAllUsers()
{
- var list = new List<User>();
-
using (var connection = GetConnection(true))
{
- foreach (var row in connection.Query("select id,guid,data from LocalUsersv2"))
- {
- list.Add(GetUser(row));
- }
+ return new List<User>(RetrieveAllUsers(connection));
}
+ }
- return list;
+ /// <summary>
+ /// Retrieve all users from the database
+ /// </summary>
+ /// <returns>IEnumerable{User}.</returns>
+ private IEnumerable<User> RetrieveAllUsers(ManagedConnection connection)
+ {
+ foreach (var row in connection.Query("select id,guid,data from LocalUsersv2"))
+ {
+ yield return GetUser(row);
+ }
}
/// <summary>