diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-01-29 01:06:24 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-01-29 01:06:24 -0500 |
| commit | a6145e54d901095e5b67704e3103843b4b515681 (patch) | |
| tree | 6623af8c44fb3b7d3945172eac7d752160804cd4 /MediaBrowser.Server.Implementations | |
| parent | 82fe244fa14029de7da2492598554e2eeed06d3e (diff) | |
support in-home easy password
Diffstat (limited to 'MediaBrowser.Server.Implementations')
3 files changed, 46 insertions, 21 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index 6b6f5b1b6..a001b25b6 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -275,9 +275,9 @@ namespace MediaBrowser.Server.Implementations.Library private string GetLocalPasswordHash(User user) { - return string.IsNullOrEmpty(user.LocalPassword) + return string.IsNullOrEmpty(user.EasyPassword) ? GetSha1String(string.Empty) - : user.LocalPassword; + : user.EasyPassword; } private bool IsPasswordEmpty(string passwordHash) @@ -355,18 +355,20 @@ namespace MediaBrowser.Server.Implementations.Library var passwordHash = GetPasswordHash(user); - var hasConfiguredDefaultPassword = !IsPasswordEmpty(passwordHash); + var hasConfiguredPassword = !IsPasswordEmpty(passwordHash); + var hasConfiguredEasyPassword = !IsPasswordEmpty(GetLocalPasswordHash(user)); var hasPassword = user.Configuration.EnableLocalPassword && !string.IsNullOrEmpty(remoteEndPoint) && _networkManager.IsInLocalNetwork(remoteEndPoint) ? - !IsPasswordEmpty(GetLocalPasswordHash(user)) : - hasConfiguredDefaultPassword; + hasConfiguredEasyPassword : + hasConfiguredPassword; var dto = new UserDto { Id = user.Id.ToString("N"), Name = user.Name, HasPassword = hasPassword, - HasConfiguredPassword = hasConfiguredDefaultPassword, + HasConfiguredPassword = hasConfiguredPassword, + HasConfiguredEasyPassword = hasConfiguredEasyPassword, LastActivityDate = user.LastActivityDate, LastLoginDate = user.LastLoginDate, Configuration = user.Configuration, @@ -613,18 +615,11 @@ namespace MediaBrowser.Server.Implementations.Library return ChangePassword(user, GetSha1String(string.Empty)); } - /// <summary> - /// Changes the password. - /// </summary> - /// <param name="user">The user.</param> - /// <param name="newPasswordSha1">The new password sha1.</param> - /// <returns>Task.</returns> - /// <exception cref="System.ArgumentNullException"> - /// user - /// or - /// newPassword - /// </exception> - /// <exception cref="System.ArgumentException">Passwords for guests cannot be changed.</exception> + public Task ResetEasyPassword(User user) + { + return ChangeEasyPassword(user, GetSha1String(string.Empty)); + } + public async Task ChangePassword(User user, string newPasswordSha1) { if (user == null) @@ -648,6 +643,29 @@ namespace MediaBrowser.Server.Implementations.Library EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs<User>(user), _logger); } + public async Task ChangeEasyPassword(User user, string newPasswordSha1) + { + if (user == null) + { + throw new ArgumentNullException("user"); + } + if (string.IsNullOrWhiteSpace(newPasswordSha1)) + { + throw new ArgumentNullException("newPasswordSha1"); + } + + if (user.ConnectLinkType.HasValue && user.ConnectLinkType.Value == UserLinkType.Guest) + { + throw new ArgumentException("Passwords for guests cannot be changed."); + } + + user.EasyPassword = newPasswordSha1; + + await UpdateUser(user).ConfigureAwait(false); + + EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs<User>(user), _logger); + } + /// <summary> /// Instantiates the new user. /// </summary> diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index ede08a49c..2dcd6eca5 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -14,9 +14,12 @@ "FileReadError": "An error occurred while reading the file.", "DeleteUser": "Delete User", "DeleteUserConfirmation": "Are you sure you wish to delete this user?", - "PasswordResetHeader": "Password Reset", + "PasswordResetHeader": "Reset Password", "PasswordResetComplete": "The password has been reset.", + "PinCodeResetComplete": "The pin code has been reset.", "PasswordResetConfirmation": "Are you sure you wish to reset the password?", + "PinCodeResetConfirmation": "Are you sure you wish to reset the pin code?", + "HeaderPinCodeReset": "Reset Pin Code", "PasswordSaved": "Password saved.", "PasswordMatchError": "Password and password confirmation must match.", "OptionRelease": "Official Release", diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 3e9c75220..93ef75dc3 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -56,6 +56,7 @@ "HeaderVideo": "Video", "HeaderPaths": "Paths", "CategorySync": "Sync", + "HeaderEasyPinCode": "Easy Pin Code", "RegisterWithPayPal": "Register with PayPal", "HeaderSyncRequiresSupporterMembership": "Sync Requires a Supporter Membership", "HeaderEnjoyDayTrial": "Enjoy a 14 Day Free Trial", @@ -1132,11 +1133,14 @@ "LabelDisplayFoldersView": "Display a folders view to show plain media folders", "ViewTypeLiveTvRecordingGroups": "Recordings", "ViewTypeLiveTvChannels": "Channels", - "LabelAllowLocalAccessWithoutPassword": "Allow local access without a password", - "LabelAllowLocalAccessWithoutPasswordHelp": "When enabled, a password will not be required when signing in from within your home network.", + "LabelEasyPinCode": "Easy pin code:", + "EasyPasswordHelp": "Your easy pin code is used for offline access with supported Media Browser apps, and can also be used for easy in-network sign in.", + "LabelInNetworkSignInWithEasyPassword": "Enable in-network sign in with my easy pin code", + "LabelInNetworkSignInWithEasyPasswordHelp": "If enabled, you'll be able to use your easy pin code to sign in to Media Browser apps from inside your home network. Your regular password will only be needed away from home. If the pin code is left blank, you won't need a password within your home network.", "HeaderPassword": "Password", "HeaderLocalAccess": "Local Access", "HeaderViewOrder": "View Order", + "ButtonResetEasyPassword": "Reset easy pin code", "LabelSelectUserViewOrder": "Choose the order your views will be displayed in within Media Browser apps", "LabelMetadataRefreshMode": "Metadata refresh mode:", "LabelImageRefreshMode": "Image refresh mode:", |
