Fix emby/users/public not taking into account first run
The previous implementation was not taking in account the first seup phase. Now the check has been added. A little method refactor has been done in order to make the code more elegant.
This commit is contained in:
parent
737d4d2b3f
commit
cd471ed4df
|
@ -273,29 +273,31 @@ namespace MediaBrowser.Api
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetPublicUsers request)
|
||||
{
|
||||
var users = _userManager
|
||||
var result = _userManager
|
||||
.Users
|
||||
.Where(item => !item.Policy.IsDisabled)
|
||||
.Where(item => !item.Policy.IsHidden);
|
||||
.Where(item => !item.Policy.IsDisabled);
|
||||
|
||||
if (ServerConfigurationManager.Configuration.IsStartupWizardCompleted)
|
||||
{
|
||||
var deviceId = _authContext.GetAuthorizationInfo(Request).DeviceId;
|
||||
result = result.Where(item => !item.Policy.IsHidden);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(deviceId))
|
||||
{
|
||||
users = users.Where(i => _deviceManager.CanAccessDevice(i, deviceId));
|
||||
result = result.Where(i => _deviceManager.CanAccessDevice(i, deviceId));
|
||||
}
|
||||
|
||||
if (!_networkManager.IsInLocalNetwork(Request.RemoteIp))
|
||||
{
|
||||
users = users.Where(i => i.Policy.EnableRemoteAccess);
|
||||
result = result.Where(i => i.Policy.EnableRemoteAccess);
|
||||
}
|
||||
}
|
||||
|
||||
var result = users
|
||||
return ToOptimizedResult(result
|
||||
.OrderBy(u => u.Name)
|
||||
.Select(i => _userManager.GetPublicUserDto(i, Request.RemoteIp))
|
||||
.ToArray();
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
.ToArray()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user