diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-08-26 20:32:33 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-08-26 20:32:33 -0400 |
| commit | e287e3a50d0f83a43905c17434e928fd6d754d9f (patch) | |
| tree | 4d24f51de4480cd7ff08b928e33dcbf5f6693a79 /Emby.Server.Implementations/Library/UserManager.cs | |
| parent | 749a181fac6d4ebc77047d8b9dd262abe3bd40d5 (diff) | |
remove async when there's nothing to await
Diffstat (limited to 'Emby.Server.Implementations/Library/UserManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Library/UserManager.cs | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index 211c54cee..e5fe2969f 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -160,9 +160,9 @@ namespace Emby.Server.Implementations.Library return Users.FirstOrDefault(u => string.Equals(u.Name, name, StringComparison.OrdinalIgnoreCase)); } - public async Task Initialize() + public void Initialize() { - Users = await LoadUsers().ConfigureAwait(false); + Users = LoadUsers(); var users = Users.ToList(); @@ -174,7 +174,7 @@ namespace Emby.Server.Implementations.Library if (!user.ConnectLinkType.HasValue || user.ConnectLinkType.Value == UserLinkType.LinkedUser) { user.Policy.IsAdministrator = true; - await UpdateUserPolicy(user, user.Policy, false).ConfigureAwait(false); + UpdateUserPolicy(user, user.Policy, false); } } } @@ -294,12 +294,12 @@ namespace Emby.Server.Implementations.Library if (success) { user.LastActivityDate = user.LastLoginDate = DateTime.UtcNow; - await UpdateUser(user).ConfigureAwait(false); - await UpdateInvalidLoginAttemptCount(user, 0).ConfigureAwait(false); + UpdateUser(user); + UpdateInvalidLoginAttemptCount(user, 0); } else { - await UpdateInvalidLoginAttemptCount(user, user.Policy.InvalidLoginAttemptCount + 1).ConfigureAwait(false); + UpdateInvalidLoginAttemptCount(user, user.Policy.InvalidLoginAttemptCount + 1); } _logger.Info("Authentication request for {0} {1}.", user.Name, success ? "has succeeded" : "has been denied"); @@ -307,7 +307,7 @@ namespace Emby.Server.Implementations.Library return success ? user : null; } - private async Task UpdateInvalidLoginAttemptCount(User user, int newValue) + private void UpdateInvalidLoginAttemptCount(User user, int newValue) { if (user.Policy.InvalidLoginAttemptCount != newValue || newValue > 0) { @@ -327,7 +327,7 @@ namespace Emby.Server.Implementations.Library //fireLockout = true; } - await UpdateUserPolicy(user, user.Policy, false).ConfigureAwait(false); + UpdateUserPolicy(user, user.Policy, false); if (fireLockout) { @@ -372,7 +372,7 @@ namespace Emby.Server.Implementations.Library /// Loads the users from the repository /// </summary> /// <returns>IEnumerable{User}.</returns> - private async Task<IEnumerable<User>> LoadUsers() + private List<User> LoadUsers() { var users = UserRepository.RetrieveAllUsers().ToList(); @@ -385,14 +385,14 @@ namespace Emby.Server.Implementations.Library user.DateLastSaved = DateTime.UtcNow; - await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false); + UserRepository.SaveUser(user, CancellationToken.None); users.Add(user); user.Policy.IsAdministrator = true; user.Policy.EnableContentDeletion = true; user.Policy.EnableRemoteControlOfOtherUsers = true; - await UpdateUserPolicy(user, user.Policy, false).ConfigureAwait(false); + UpdateUserPolicy(user, user.Policy, false); } return users; @@ -539,7 +539,7 @@ namespace Emby.Server.Implementations.Library /// <param name="user">The user.</param> /// <exception cref="System.ArgumentNullException">user</exception> /// <exception cref="System.ArgumentException"></exception> - public async Task UpdateUser(User user) + public void UpdateUser(User user) { if (user == null) { @@ -554,7 +554,7 @@ namespace Emby.Server.Implementations.Library user.DateModified = DateTime.UtcNow; user.DateLastSaved = DateTime.UtcNow; - await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false); + UserRepository.SaveUser(user, CancellationToken.None); OnUserUpdated(user); } @@ -599,7 +599,7 @@ namespace Emby.Server.Implementations.Library user.DateLastSaved = DateTime.UtcNow; - await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false); + UserRepository.SaveUser(user, CancellationToken.None); EventHelper.QueueEventIfNotNull(UserCreated, this, new GenericEventArgs<User> { Argument = user }, _logger); @@ -653,7 +653,7 @@ namespace Emby.Server.Implementations.Library { var configPath = GetConfigurationFilePath(user); - await UserRepository.DeleteUser(user, CancellationToken.None).ConfigureAwait(false); + UserRepository.DeleteUser(user, CancellationToken.None); try { @@ -667,7 +667,7 @@ namespace Emby.Server.Implementations.Library DeleteUserPolicy(user); // Force this to be lazy loaded again - Users = await LoadUsers().ConfigureAwait(false); + Users = LoadUsers(); OnUserDeleted(user); } @@ -681,17 +681,17 @@ namespace Emby.Server.Implementations.Library /// Resets the password by clearing it. /// </summary> /// <returns>Task.</returns> - public Task ResetPassword(User user) + public void ResetPassword(User user) { - return ChangePassword(user, GetSha1String(string.Empty)); + ChangePassword(user, GetSha1String(string.Empty)); } - public Task ResetEasyPassword(User user) + public void ResetEasyPassword(User user) { - return ChangeEasyPassword(user, GetSha1String(string.Empty)); + ChangeEasyPassword(user, GetSha1String(string.Empty)); } - public async Task ChangePassword(User user, string newPasswordSha1) + public void ChangePassword(User user, string newPasswordSha1) { if (user == null) { @@ -709,12 +709,12 @@ namespace Emby.Server.Implementations.Library user.Password = newPasswordSha1; - await UpdateUser(user).ConfigureAwait(false); + UpdateUser(user); EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs<User>(user), _logger); } - public async Task ChangeEasyPassword(User user, string newPasswordSha1) + public void ChangeEasyPassword(User user, string newPasswordSha1) { if (user == null) { @@ -727,7 +727,7 @@ namespace Emby.Server.Implementations.Library user.EasyPassword = newPasswordSha1; - await UpdateUser(user).ConfigureAwait(false); + UpdateUser(user); EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs<User>(user), _logger); } @@ -842,7 +842,7 @@ namespace Emby.Server.Implementations.Library }; } - public async Task<PinRedeemResult> RedeemPasswordResetPin(string pin) + public PinRedeemResult RedeemPasswordResetPin(string pin) { DeletePinFile(); @@ -863,12 +863,12 @@ namespace Emby.Server.Implementations.Library foreach (var user in users) { - await ResetPassword(user).ConfigureAwait(false); + ResetPassword(user); if (user.Policy.IsDisabled) { user.Policy.IsDisabled = false; - await UpdateUserPolicy(user, user.Policy, true).ConfigureAwait(false); + UpdateUserPolicy(user, user.Policy, true); } usersReset.Add(user.Name); } @@ -945,13 +945,13 @@ namespace Emby.Server.Implementations.Library } private readonly object _policySyncLock = new object(); - public Task UpdateUserPolicy(string userId, UserPolicy userPolicy) + public void UpdateUserPolicy(string userId, UserPolicy userPolicy) { var user = GetUserById(userId); - return UpdateUserPolicy(user, userPolicy, true); + UpdateUserPolicy(user, userPolicy, true); } - private async Task UpdateUserPolicy(User user, UserPolicy userPolicy, bool fireEvent) + private void UpdateUserPolicy(User user, UserPolicy userPolicy, bool fireEvent) { // The xml serializer will output differently if the type is not exact if (userPolicy.GetType() != typeof(UserPolicy)) @@ -970,7 +970,7 @@ namespace Emby.Server.Implementations.Library user.Policy = userPolicy; } - await UpdateConfiguration(user, user.Configuration, true).ConfigureAwait(false); + UpdateConfiguration(user, user.Configuration, true); } private void DeleteUserPolicy(User user) @@ -1032,13 +1032,13 @@ namespace Emby.Server.Implementations.Library } private readonly object _configSyncLock = new object(); - public Task UpdateConfiguration(string userId, UserConfiguration config) + public void UpdateConfiguration(string userId, UserConfiguration config) { var user = GetUserById(userId); - return UpdateConfiguration(user, config, true); + UpdateConfiguration(user, config, true); } - private async Task UpdateConfiguration(User user, UserConfiguration config, bool fireEvent) + private void UpdateConfiguration(User user, UserConfiguration config, bool fireEvent) { var path = GetConfigurationFilePath(user); |
