diff options
| author | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-20 20:33:05 -0500 |
|---|---|---|
| committer | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-20 20:33:05 -0500 |
| commit | 767cdc1f6f6a63ce997fc9476911e2c361f9d402 (patch) | |
| tree | 49add55976f895441167c66cfa95e5c7688d18ce /MediaBrowser.WebDashboard/Html/scripts/UpdatePasswordPage.js | |
| parent | 845554722efaed872948a9e0f7202e3ef52f1b6e (diff) | |
Pushing missing changes
Diffstat (limited to 'MediaBrowser.WebDashboard/Html/scripts/UpdatePasswordPage.js')
| -rw-r--r-- | MediaBrowser.WebDashboard/Html/scripts/UpdatePasswordPage.js | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/MediaBrowser.WebDashboard/Html/scripts/UpdatePasswordPage.js b/MediaBrowser.WebDashboard/Html/scripts/UpdatePasswordPage.js new file mode 100644 index 000000000..9c3a009b2 --- /dev/null +++ b/MediaBrowser.WebDashboard/Html/scripts/UpdatePasswordPage.js @@ -0,0 +1,88 @@ +var UpdatePasswordPage = { + + onPageShow: function () { + UpdatePasswordPage.loadUser(); + }, + + loadUser: function() { + var page = $.mobile.activePage; + + var userid = getParameterByName("userId"); + + ApiClient.getUser(userid).done(function (user) { + + Dashboard.setPageTitle(user.Name); + + if (user.HasPassword) { + $('#btnResetPassword', page).show(); + } else { + $('#btnResetPassword', page).hide(); + } + + }); + + $('#txtCurrentPassword', page).val(''); + $('#txtNewPassword', page).val(''); + $('#txtNewPasswordConfirm', page).val(''); + }, + + save: function () { + + var userId = getParameterByName("userId"); + + var page = $($.mobile.activePage); + var currentPassword = $('#txtCurrentPassword', page).val(); + var newPassword = $('#txtNewPassword', page).val(); + + ApiClient.updateUserPassword(userId, currentPassword, newPassword).done(UpdatePasswordPage.saveComplete); + }, + + saveComplete: function () { + + Dashboard.hideLoadingMsg(); + + Dashboard.alert("Password saved."); + UpdatePasswordPage.loadUser(); + }, + + resetPassword: function () { + + var msg = "Are you sure you wish to reset the password?"; + + Dashboard.confirm(msg, "Password Reset", function (result) { + + if (result) { + var userId = getParameterByName("userId"); + + Dashboard.showLoadingMsg(); + + ApiClient.resetUserPassword(userId).done(function () { + + Dashboard.hideLoadingMsg(); + Dashboard.alert("The password has been reset."); + UpdatePasswordPage.loadUser(); + + }); + } + }); + }, + + onSubmit: function () { + var page = $($.mobile.activePage); + + if ($('#txtNewPassword', page).val() != $('#txtNewPasswordConfirm', page).val()) { + + Dashboard.showError("Password and password confirmation must match."); + return false; + } + + Dashboard.showLoadingMsg(); + + UpdatePasswordPage.save(); + + // Disable default form submission + return false; + } +}; + +$(document).on('pageshow', "#updatePasswordPage", UpdatePasswordPage.onPageShow);
\ No newline at end of file |
