mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 05:47:14 -04:00
Update Emby.Server.Implementations/Library/DefaultPasswordResetProvider.cs
Co-Authored-By: LogicalPhallacy <44458166+LogicalPhallacy@users.noreply.github.com>
This commit is contained in:
parent
6be8624373
commit
b07c146fd9
@ -40,7 +40,10 @@ namespace Emby.Server.Implementations.Library
|
|||||||
HashSet<string> usersreset = new HashSet<string>();
|
HashSet<string> usersreset = new HashSet<string>();
|
||||||
foreach (var resetfile in Directory.EnumerateFiles(_passwordResetFileBaseDir, $"{_passwordResetFileBaseName}*"))
|
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)
|
if (spr.ExpirationDate < DateTime.Now)
|
||||||
{
|
{
|
||||||
File.Delete(resetfile);
|
File.Delete(resetfile);
|
||||||
@ -51,7 +54,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
if (resetUser != null)
|
if (resetUser != null)
|
||||||
{
|
{
|
||||||
await _userManager.ChangePassword(resetUser, pin).ConfigureAwait(false);
|
await _userManager.ChangePassword(resetUser, pin).ConfigureAwait(false);
|
||||||
usersreset.Add(resetUser.Name);
|
usersreset.Add(resetUser.Name);
|
||||||
File.Delete(resetfile);
|
File.Delete(resetfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,8 +88,8 @@ namespace Emby.Server.Implementations.Library
|
|||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileStream fileStream = File.OpenWrite(filePath);
|
FileStream fileStream = File.OpenWrite(filePath);
|
||||||
_jsonSerializer.SerializeToStream(spr,fileStream);
|
_jsonSerializer.SerializeToStream(spr,fileStream);
|
||||||
await fileStream.FlushAsync().ConfigureAwait(false);
|
await fileStream.FlushAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user