mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 19:08:18 -07:00
support in-home easy password
This commit is contained in:
parent
340fcbb607
commit
27b770b898
@ -94,20 +94,30 @@
|
||||
<form class="localAccessForm localAccessSection userProfileSettingsForm" style="margin: 0 auto;">
|
||||
<div class="detailSection">
|
||||
<div class="detailSectionHeader">
|
||||
${HeaderLocalAccess}
|
||||
${HeaderEasyPinCode}
|
||||
</div>
|
||||
<div class="detailSectionContent">
|
||||
<br />
|
||||
<div>${EasyPasswordHelp}</div>
|
||||
<br />
|
||||
<div>
|
||||
<label for="chkEnableLocalAccessWithoutPassword">${LabelAllowLocalAccessWithoutPassword}</label>
|
||||
<input type="checkbox" id="chkEnableLocalAccessWithoutPassword" />
|
||||
<div class="fieldDescription">${LabelAllowLocalAccessWithoutPasswordHelp}</div>
|
||||
<label for="txtEasyPassword">${LabelEasyPinCode}</label>
|
||||
<input type="password" id="txtEasyPassword" />
|
||||
</div>
|
||||
<br />
|
||||
<div>
|
||||
<button type="submit" data-theme="b" data-icon="check">
|
||||
<label for="chkEnableLocalEasyPassword">${LabelInNetworkSignInWithEasyPassword}</label>
|
||||
<input type="checkbox" id="chkEnableLocalEasyPassword" />
|
||||
<div class="fieldDescription">${LabelInNetworkSignInWithEasyPasswordHelp}</div>
|
||||
</div>
|
||||
<br />
|
||||
<div>
|
||||
<button type="submit" data-theme="b" data-icon="check" data-mini="true">
|
||||
${ButtonSave}
|
||||
</button>
|
||||
<button id="btnResetEasyPassword" style="display:none;" type="button" data-icon="lock" onclick="UpdatePasswordPage.resetEasyPassword();" data-mini="true">
|
||||
${ButtonResetEasyPassword}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user