mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Remove legacy code that accessed config.xml without a lock
(cherry picked from commit 383e5208f4cb9673c306aa5011463586c1972707)
This commit is contained in:
@@ -19,7 +19,7 @@ namespace NzbDrone.Core.Authentication
|
|||||||
User FindUser(Guid identifier);
|
User FindUser(Guid identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UserService : IUserService, IHandle<ApplicationStartedEvent>
|
public class UserService : IUserService
|
||||||
{
|
{
|
||||||
private readonly IUserRepository _repo;
|
private readonly IUserRepository _repo;
|
||||||
private readonly IAppFolderInfo _appFolderInfo;
|
private readonly IAppFolderInfo _appFolderInfo;
|
||||||
@@ -97,35 +97,5 @@ namespace NzbDrone.Core.Authentication
|
|||||||
{
|
{
|
||||||
return _repo.FindUser(identifier);
|
return _repo.FindUser(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(ApplicationStartedEvent message)
|
|
||||||
{
|
|
||||||
if (_repo.All().Any())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var configFile = _appFolderInfo.GetConfigPath();
|
|
||||||
|
|
||||||
if (!_diskProvider.FileExists(configFile))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var xDoc = XDocument.Load(configFile);
|
|
||||||
var config = xDoc.Descendants("Config").Single();
|
|
||||||
var usernameElement = config.Descendants("Username").FirstOrDefault();
|
|
||||||
var passwordElement = config.Descendants("Password").FirstOrDefault();
|
|
||||||
|
|
||||||
if (usernameElement == null || passwordElement == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var username = usernameElement.Value;
|
|
||||||
var password = passwordElement.Value;
|
|
||||||
|
|
||||||
Add(username, password);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user