2013-04-18 12:09:07 -07:00
|
|
|
|
(function ($, document, window) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
function loadUser(page) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
var userid = getParameterByName("userId");
|
|
|
|
|
|
|
|
|
|
ApiClient.getUser(userid).done(function (user) {
|
|
|
|
|
|
|
|
|
|
Dashboard.setPageTitle(user.Name);
|
|
|
|
|
|
|
|
|
|
if (user.HasPassword) {
|
|
|
|
|
$('#btnResetPassword', page).show();
|
2013-03-26 20:01:13 -07:00
|
|
|
|
$('#fldCurrentPassword', page).show();
|
2013-12-24 11:37:29 -07:00
|
|
|
|
$('.formheader', page).hide();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
} else {
|
|
|
|
|
$('#btnResetPassword', page).hide();
|
2013-03-26 20:01:13 -07:00
|
|
|
|
$('#fldCurrentPassword', page).hide();
|
2014-04-01 15:23:07 -07:00
|
|
|
|
$('.formheader', page).show();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#txtCurrentPassword', page).val('');
|
|
|
|
|
$('#txtNewPassword', page).val('');
|
|
|
|
|
$('#txtNewPasswordConfirm', page).val('');
|
2013-04-18 12:09:07 -07:00
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
function save(page) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
var userId = getParameterByName("userId");
|
|
|
|
|
|
|
|
|
|
var currentPassword = $('#txtCurrentPassword', page).val();
|
|
|
|
|
var newPassword = $('#txtNewPassword', page).val();
|
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
ApiClient.updateUserPassword(userId, currentPassword, newPassword).done(function () {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-03-30 19:33:10 -07:00
|
|
|
|
Dashboard.alert(Globalize.translate("PasswordSaved"));
|
2013-04-18 12:09:07 -07:00
|
|
|
|
loadUser(page);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
});
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
function updatePasswordPage() {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
var self = this;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
self.onSubmit = function () {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
var page = $.mobile.activePage;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
if ($('#txtNewPassword', page).val() != $('#txtNewPasswordConfirm', page).val()) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-03-30 19:33:10 -07:00
|
|
|
|
Dashboard.showError(Globalize.translate("PasswordMatchError"));
|
2013-04-18 12:09:07 -07:00
|
|
|
|
return false;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
save(page);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
// Disable default form submission
|
2013-02-20 18:33:05 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.resetPassword = function () {
|
|
|
|
|
|
2014-03-30 19:33:10 -07:00
|
|
|
|
var msg = Globalize.translate("PasswordResetConfirmation");
|
2013-04-18 12:09:07 -07:00
|
|
|
|
|
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
|
|
2014-03-30 19:33:10 -07:00
|
|
|
|
Dashboard.confirm(msg, Globalize.translate("PasswordResetHeader"), function (result) {
|
2013-04-18 12:09:07 -07:00
|
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
|
var userId = getParameterByName("userId");
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
ApiClient.resetUserPassword(userId).done(function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-12-26 19:23:57 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.alert({
|
2014-03-30 19:33:10 -07:00
|
|
|
|
message: Globalize.translate("PasswordResetComplete"),
|
|
|
|
|
title: Globalize.translate("PasswordResetHeader")
|
2013-12-26 19:23:57 -07:00
|
|
|
|
});
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
loadUser(page);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
};
|
2013-02-20 18:33:05 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-18 12:09:07 -07:00
|
|
|
|
window.UpdatePasswordPage = new updatePasswordPage();
|
|
|
|
|
|
|
|
|
|
$(document).on('pagebeforeshow', "#updatePasswordPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
Dashboard.getCurrentUser().done(function (loggedInUser) {
|
|
|
|
|
|
|
|
|
|
if (loggedInUser.Configuration.IsAdministrator) {
|
2013-12-26 08:40:38 -07:00
|
|
|
|
$('#lnkParentalControl', page).show();
|
2013-04-18 12:09:07 -07:00
|
|
|
|
} else {
|
2013-12-26 08:40:38 -07:00
|
|
|
|
$('#lnkParentalControl', page).hide();
|
2013-04-18 12:09:07 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}).on('pageshow', "#updatePasswordPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
loadUser(page);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, window);
|