Update Emby.Server.Implementations/Library/DefaultPasswordResetProvider.cs

Co-Authored-By: LogicalPhallacy <44458166+LogicalPhallacy@users.noreply.github.com>
This commit is contained in:
Bond-009 2019-03-27 16:17:18 -07:00 committed by GitHub
parent 6be8624373
commit b07c146fd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,7 +40,10 @@ namespace Emby.Server.Implementations.Library
HashSet<string> usersreset = new HashSet<string>();
foreach (var resetfile in Directory.EnumerateFiles(_passwordResetFileBaseDir, $"{_passwordResetFileBaseName}*"))
{
var spr = await _jsonSerializer.DeserializeFromStreamAsync<SerializablePasswordReset>(File.OpenRead(resetfile)).ConfigureAwait(false);
using (var str = File.OpenRead(resetfile))
{
var spr = await _jsonSerializer.DeserializeFromStreamAsync<SerializablePasswordReset>(str).ConfigureAwait(false);
}
if (spr.ExpirationDate < DateTime.Now)
{
File.Delete(resetfile);
@ -51,7 +54,7 @@ namespace Emby.Server.Implementations.Library
if (resetUser != null)
{
await _userManager.ChangePassword(resetUser, pin).ConfigureAwait(false);
usersreset.Add(resetUser.Name);
usersreset.Add(resetUser.Name);
File.Delete(resetfile);
}
}
@ -85,8 +88,8 @@ namespace Emby.Server.Implementations.Library
};
try
{
FileStream fileStream = File.OpenWrite(filePath);
{
FileStream fileStream = File.OpenWrite(filePath);
_jsonSerializer.SerializeToStream(spr,fileStream);
await fileStream.FlushAsync().ConfigureAwait(false);
}