diff --git a/dashboard-ui/myprofile.html b/dashboard-ui/myprofile.html index e2e7684a23..ac36da4359 100644 --- a/dashboard-ui/myprofile.html +++ b/dashboard-ui/myprofile.html @@ -94,20 +94,30 @@
- ${HeaderLocalAccess} + ${HeaderEasyPinCode}
+
+
${EasyPasswordHelp}

- - -
${LabelAllowLocalAccessWithoutPasswordHelp}
+ +

-
+
+
+ +
diff --git a/dashboard-ui/scripts/myprofile.js b/dashboard-ui/scripts/myprofile.js index ccc34183ee..22174f9823 100644 --- a/dashboard-ui/scripts/myprofile.js +++ b/dashboard-ui/scripts/myprofile.js @@ -248,7 +248,15 @@ $('.passwordSection', page).show(); } - $('#chkEnableLocalAccessWithoutPassword', page).checked(user.Configuration.EnableLocalPassword).checkboxradio('refresh'); + if (user.HasConfiguredEasyPassword) { + $('#txtEasyPassword', page).val('').attr('placeholder', '******'); + $('#btnResetEasyPassword', page).show(); + } else { + $('#txtEasyPassword', page).val('').attr('placeholder', ''); + $('#btnResetEasyPassword', page).hide(); + } + + $('#chkEnableLocalEasyPassword', page).checked(user.Configuration.EnableLocalPassword).checkboxradio('refresh'); }); $('#txtCurrentPassword', page).val(''); @@ -256,13 +264,30 @@ $('#txtNewPasswordConfirm', page).val(''); } - function save(page) { + function saveEasyPassword(page) { var userId = getParameterByName("userId"); + var easyPassword = $('#txtEasyPassword', page).val(); + + if (easyPassword) { + + ApiClient.updateEasyPassword(userId, easyPassword).done(function () { + + onEasyPasswordSaved(page, userId); + + }); + + } else { + onEasyPasswordSaved(page, userId); + } + } + + function onEasyPasswordSaved(page, userId) { + ApiClient.getUser(userId).done(function (user) { - user.Configuration.EnableLocalPassword = $('#chkEnableLocalAccessWithoutPassword', page).checked(); + user.Configuration.EnableLocalPassword = $('#chkEnableLocalEasyPassword', page).checked(); ApiClient.updateUserConfiguration(user.Id, user.Configuration).done(function () { @@ -321,7 +346,7 @@ Dashboard.showLoadingMsg(); - save(page); + saveEasyPassword(page); // Disable default form submission return false; @@ -357,6 +382,36 @@ }); }; + + self.resetEasyPassword = function () { + + var msg = Globalize.translate('PinCodeResetConfirmation'); + + var page = $.mobile.activePage; + + Dashboard.confirm(msg, Globalize.translate('HeaderPinCodeReset'), function (result) { + + if (result) { + var userId = getParameterByName("userId"); + + Dashboard.showLoadingMsg(); + + ApiClient.resetEasyPassword(userId).done(function () { + + Dashboard.hideLoadingMsg(); + + Dashboard.alert({ + message: Globalize.translate('PinCodeResetComplete'), + title: Globalize.translate('HeaderPinCodeReset') + }); + + loadUser(page); + + }); + } + }); + + }; } window.UpdatePasswordPage = new updatePasswordPage(); diff --git a/dashboard-ui/thirdparty/apiclient/mediabrowser.apiclient.js b/dashboard-ui/thirdparty/apiclient/mediabrowser.apiclient.js index 19f30bcb36..5b313c358b 100644 --- a/dashboard-ui/thirdparty/apiclient/mediabrowser.apiclient.js +++ b/dashboard-ui/thirdparty/apiclient/mediabrowser.apiclient.js @@ -2498,6 +2498,28 @@ }); }; + /** + * Updates a user's easy password + * @param {String} userId + * @param {String} newPassword + */ + self.updateEasyPassword = function (userId, newPassword) { + + if (!userId) { + throw new Error("null userId"); + } + + var url = self.getUrl("Users/" + userId + "/EasyPassword"); + + return self.ajax({ + type: "POST", + url: url, + data: { + newPassword: CryptoJS.SHA1(newPassword).toString() + } + }); + }; + /** * Resets a user's password * @param {String} userId @@ -2523,6 +2545,27 @@ }); }; + self.resetEasyPassword = function (userId) { + + if (!userId) { + throw new Error("null userId"); + } + + var url = self.getUrl("Users/" + userId + "/EasyPassword"); + + var postData = { + + }; + + postData.resetPassword = true; + + return self.ajax({ + type: "POST", + url: url, + data: postData + }); + }; + /** * Updates the server's configuration * @param {Object} configuration