aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/UserManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Library/UserManager.cs')
-rw-r--r--Emby.Server.Implementations/Library/UserManager.cs60
1 files changed, 19 insertions, 41 deletions
diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs
index 6e4450bb1..6dd9366b0 100644
--- a/Emby.Server.Implementations/Library/UserManager.cs
+++ b/Emby.Server.Implementations/Library/UserManager.cs
@@ -23,7 +23,6 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Security;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Configuration;
-using MediaBrowser.Model.Connect;
using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
@@ -211,11 +210,8 @@ namespace Emby.Server.Implementations.Library
{
foreach (var user in users)
{
- if (!user.ConnectLinkType.HasValue || user.ConnectLinkType.Value == UserLinkType.LinkedUser)
- {
- user.Policy.IsAdministrator = true;
- UpdateUserPolicy(user, user.Policy, false);
- }
+ user.Policy.IsAdministrator = true;
+ UpdateUserPolicy(user, user.Policy, false);
}
}
}
@@ -273,13 +269,9 @@ namespace Emby.Server.Implementations.Library
if (user != null)
{
- // Authenticate using local credentials if not a guest
- if (!user.ConnectLinkType.HasValue || user.ConnectLinkType.Value != UserLinkType.Guest)
- {
- var authResult = await AuthenticateLocalUser(username, password, hashedPassword, user, remoteEndPoint).ConfigureAwait(false);
- authenticationProvider = authResult.Item1;
- success = authResult.Item2;
- }
+ var authResult = await AuthenticateLocalUser(username, password, hashedPassword, user, remoteEndPoint).ConfigureAwait(false);
+ authenticationProvider = authResult.Item1;
+ success = authResult.Item2;
}
else
{
@@ -554,9 +546,6 @@ namespace Emby.Server.Implementations.Library
LastActivityDate = user.LastActivityDate,
LastLoginDate = user.LastLoginDate,
Configuration = user.Configuration,
- ConnectLinkType = user.ConnectLinkType,
- ConnectUserId = user.ConnectUserId,
- ConnectUserName = user.ConnectUserName,
ServerId = _appHost.SystemId,
Policy = user.Policy
};
@@ -815,11 +804,6 @@ namespace Emby.Server.Implementations.Library
throw new ArgumentNullException(nameof(user));
}
- if (user.ConnectLinkType.HasValue && user.ConnectLinkType.Value == UserLinkType.Guest)
- {
- throw new ArgumentException("Passwords for guests cannot be changed.");
- }
-
await GetAuthenticationProvider(user).ChangePassword(user, newPassword).ConfigureAwait(false);
UpdateUser(user);
@@ -904,7 +888,7 @@ namespace Emby.Server.Implementations.Library
// Tuesday, 22 August 2006 06:30 AM
text.AppendLine("The pin code will expire at " + localExpirationTime.ToString("f1", CultureInfo.CurrentCulture));
- _fileSystem.WriteAllText(path, text.ToString(), Encoding.UTF8);
+ File.WriteAllText(path, text.ToString(), Encoding.UTF8);
var result = new PasswordPinCreationResult
{
@@ -926,11 +910,6 @@ namespace Emby.Server.Implementations.Library
null :
GetUserByName(enteredUsername);
- if (user != null && user.ConnectLinkType.HasValue && user.ConnectLinkType.Value == UserLinkType.Guest)
- {
- throw new ArgumentException("Unable to process forgot password request for guests.");
- }
-
var action = ForgotPasswordAction.InNetworkRequired;
string pinFile = null;
DateTime? expirationDate = null;
@@ -975,10 +954,7 @@ namespace Emby.Server.Implementations.Library
_lastPin = null;
_lastPasswordPinCreationResult = null;
- var users = Users.Where(i => !i.ConnectLinkType.HasValue || i.ConnectLinkType.Value != UserLinkType.Guest)
- .ToList();
-
- foreach (var user in users)
+ foreach (var user in Users)
{
await ResetPassword(user).ConfigureAwait(false);
@@ -1029,6 +1005,11 @@ namespace Emby.Server.Implementations.Library
{
var path = GetPolicyFilePath(user);
+ if (!File.Exists(path))
+ {
+ return GetDefaultPolicy(user);
+ }
+
try
{
lock (_policySyncLock)
@@ -1036,10 +1017,6 @@ namespace Emby.Server.Implementations.Library
return (UserPolicy)_xmlSerializer.DeserializeFromFile(typeof(UserPolicy), path);
}
}
- catch (FileNotFoundException)
- {
- return GetDefaultPolicy(user);
- }
catch (IOException)
{
return GetDefaultPolicy(user);
@@ -1079,7 +1056,7 @@ namespace Emby.Server.Implementations.Library
var path = GetPolicyFilePath(user);
- _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
+ Directory.CreateDirectory(Path.GetDirectoryName(path));
lock (_policySyncLock)
{
@@ -1128,6 +1105,11 @@ namespace Emby.Server.Implementations.Library
{
var path = GetConfigurationFilePath(user);
+ if (!File.Exists(path))
+ {
+ return new UserConfiguration();
+ }
+
try
{
lock (_configSyncLock)
@@ -1135,10 +1117,6 @@ namespace Emby.Server.Implementations.Library
return (UserConfiguration)_xmlSerializer.DeserializeFromFile(typeof(UserConfiguration), path);
}
}
- catch (FileNotFoundException)
- {
- return new UserConfiguration();
- }
catch (IOException)
{
return new UserConfiguration();
@@ -1174,7 +1152,7 @@ namespace Emby.Server.Implementations.Library
config = _jsonSerializer.DeserializeFromString<UserConfiguration>(json);
}
- _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
+ Directory.CreateDirectory(Path.GetDirectoryName(path));
lock (_configSyncLock)
{