Merge pull request #190 from LogicalPhallacy/master

Add setting to support configurable user lockout
This commit is contained in:
Joshua M. Boniface 2019-03-25 11:02:27 -04:00 committed by GitHub
commit 2996cd7d28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 7 deletions

View File

@ -22,13 +22,45 @@ define(["jQuery", "loading", "libraryMenu", "fnchecked"], function($, loading, l
}
function loadUser(page, user) {
currentUser = user, ApiClient.getJSON(ApiClient.getUrl("Auth/Providers")).then(function(providers) {
currentUser = user;
ApiClient.getJSON(ApiClient.getUrl("Auth/Providers")).then(function(providers) {
loadAuthProviders(page, user, providers)
}), ApiClient.getJSON(ApiClient.getUrl("Library/MediaFolders", {
IsHidden: !1
});
ApiClient.getJSON(ApiClient.getUrl("Library/MediaFolders", {
IsHidden: false
})).then(function(folders) {
loadDeleteFolders(page, user, folders.Items)
}), user.Policy.IsDisabled ? $(".disabledUserBanner", page).show() : $(".disabledUserBanner", page).hide(), "Guest" == user.ConnectLinkType ? ($("#fldConnectInfo", page).hide(), $("#txtUserName", page).prop("disabled", "disabled")) : ($("#txtUserName", page).prop("disabled", "").removeAttr("disabled"), $("#fldConnectInfo", page).show()), $(".lnkEditUserPreferences", page).attr("href", "mypreferencesmenu.html?userId=" + user.Id), libraryMenu.setTitle(user.Name), page.querySelector(".username").innerHTML = user.Name, $("#txtUserName", page).val(user.Name), $("#chkIsAdmin", page).checked(user.Policy.IsAdministrator), $("#chkDisabled", page).checked(user.Policy.IsDisabled), $("#chkIsHidden", page).checked(user.Policy.IsHidden), $("#chkRemoteControlSharedDevices", page).checked(user.Policy.EnableSharedDeviceControl), $("#chkEnableRemoteControlOtherUsers", page).checked(user.Policy.EnableRemoteControlOfOtherUsers), $("#chkEnableDownloading", page).checked(user.Policy.EnableContentDownloading), $("#chkManageLiveTv", page).checked(user.Policy.EnableLiveTvManagement), $("#chkEnableLiveTvAccess", page).checked(user.Policy.EnableLiveTvAccess), $("#chkEnableMediaPlayback", page).checked(user.Policy.EnableMediaPlayback), $("#chkEnableAudioPlaybackTranscoding", page).checked(user.Policy.EnableAudioPlaybackTranscoding), $("#chkEnableVideoPlaybackTranscoding", page).checked(user.Policy.EnableVideoPlaybackTranscoding), $("#chkEnableVideoPlaybackRemuxing", page).checked(user.Policy.EnablePlaybackRemuxing), $("#chkRemoteAccess", page).checked(null == user.Policy.EnableRemoteAccess || user.Policy.EnableRemoteAccess), $("#chkEnableSyncTranscoding", page).checked(user.Policy.EnableSyncTranscoding), $("#chkEnableConversion", page).checked(user.Policy.EnableMediaConversion || !1), $("#chkEnableSharing", page).checked(user.Policy.EnablePublicSharing), $("#txtRemoteClientBitrateLimit", page).val(user.Policy.RemoteClientBitrateLimit / 1e6 || ""), loading.hide()
});
if (user.Policy.IsDisabled) {
$(".disabledUserBanner", page).show();
} else {
$(".disabledUserBanner", page).hide();
}
$("#txtUserName", page).prop("disabled", "").removeAttr("disabled");
$("#fldConnectInfo", page).show();
$(".lnkEditUserPreferences", page).attr("href", "mypreferencesmenu.html?userId=" + user.Id);
libraryMenu.setTitle(user.Name);
page.querySelector(".username").innerHTML = user.Name;
$("#txtUserName", page).val(user.Name);
$("#chkIsAdmin", page).checked(user.Policy.IsAdministrator);
$("#chkDisabled", page).checked(user.Policy.IsDisabled);
$("#chkIsHidden", page).checked(user.Policy.IsHidden);
$("#chkRemoteControlSharedDevices", page).checked(user.Policy.EnableSharedDeviceControl);
$("#chkEnableRemoteControlOtherUsers", page).checked(user.Policy.EnableRemoteControlOfOtherUsers);
$("#chkEnableDownloading", page).checked(user.Policy.EnableContentDownloading);
$("#chkManageLiveTv", page).checked(user.Policy.EnableLiveTvManagement);
$("#chkEnableLiveTvAccess", page).checked(user.Policy.EnableLiveTvAccess);
$("#chkEnableMediaPlayback", page).checked(user.Policy.EnableMediaPlayback);
$("#chkEnableAudioPlaybackTranscoding", page).checked(user.Policy.EnableAudioPlaybackTranscoding);
$("#chkEnableVideoPlaybackTranscoding", page).checked(user.Policy.EnableVideoPlaybackTranscoding);
$("#chkEnableVideoPlaybackRemuxing", page).checked(user.Policy.EnablePlaybackRemuxing);
$("#chkRemoteAccess", page).checked(null == user.Policy.EnableRemoteAccess || user.Policy.EnableRemoteAccess);
$("#chkEnableSyncTranscoding", page).checked(user.Policy.EnableSyncTranscoding);
$("#chkEnableConversion", page).checked(user.Policy.EnableMediaConversion || false);
$("#chkEnableSharing", page).checked(user.Policy.EnablePublicSharing);
$("#txtRemoteClientBitrateLimit", page).val(user.Policy.RemoteClientBitrateLimit / 1e6 || "");
$("#txtLoginAttemptsBeforeLockout", page).val(user.Policy.LoginAttemptsBeforeLockout || "0");
loading.hide();
}
function onSaveComplete(page, user) {
@ -40,11 +72,33 @@ define(["jQuery", "loading", "libraryMenu", "fnchecked"], function($, loading, l
}
function saveUser(user, page) {
user.Name = $("#txtUserName", page).val(), user.Policy.IsAdministrator = $("#chkIsAdmin", page).checked(), user.Policy.IsHidden = $("#chkIsHidden", page).checked(), user.Policy.IsDisabled = $("#chkDisabled", page).checked(), user.Policy.EnableRemoteControlOfOtherUsers = $("#chkEnableRemoteControlOtherUsers", page).checked(), user.Policy.EnableLiveTvManagement = $("#chkManageLiveTv", page).checked(), user.Policy.EnableLiveTvAccess = $("#chkEnableLiveTvAccess", page).checked(), user.Policy.EnableSharedDeviceControl = $("#chkRemoteControlSharedDevices", page).checked(), user.Policy.EnableMediaPlayback = $("#chkEnableMediaPlayback", page).checked(), user.Policy.EnableAudioPlaybackTranscoding = $("#chkEnableAudioPlaybackTranscoding", page).checked(), user.Policy.EnableVideoPlaybackTranscoding = $("#chkEnableVideoPlaybackTranscoding", page).checked(), user.Policy.EnablePlaybackRemuxing = $("#chkEnableVideoPlaybackRemuxing", page).checked(), user.Policy.EnableContentDownloading = $("#chkEnableDownloading", page).checked(), user.Policy.EnableSyncTranscoding = $("#chkEnableSyncTranscoding", page).checked(), user.Policy.EnableMediaConversion = $("#chkEnableConversion", page).checked(), user.Policy.EnablePublicSharing = $("#chkEnableSharing", page).checked(), user.Policy.EnableRemoteAccess = $("#chkRemoteAccess", page).checked(), user.Policy.RemoteClientBitrateLimit = parseInt(1e6 * parseFloat($("#txtRemoteClientBitrateLimit", page).val() || "0")), user.Policy.AuthenticationProviderId = page.querySelector(".selectLoginProvider").value, user.Policy.EnableContentDeletion = $("#chkEnableDeleteAllFolders", page).checked(), user.Policy.EnableContentDeletionFromFolders = user.Policy.EnableContentDeletion ? [] : $(".chkFolder", page).get().filter(function(c) {
user.Name = $("#txtUserName", page).val();
user.Policy.IsAdministrator = $("#chkIsAdmin", page).checked();
user.Policy.IsHidden = $("#chkIsHidden", page).checked();
user.Policy.IsDisabled = $("#chkDisabled", page).checked();
user.Policy.EnableRemoteControlOfOtherUsers = $("#chkEnableRemoteControlOtherUsers", page).checked();
user.Policy.EnableLiveTvManagement = $("#chkManageLiveTv", page).checked();
user.Policy.EnableLiveTvAccess = $("#chkEnableLiveTvAccess", page).checked();
user.Policy.EnableSharedDeviceControl = $("#chkRemoteControlSharedDevices", page).checked();
user.Policy.EnableMediaPlayback = $("#chkEnableMediaPlayback", page).checked();
user.Policy.EnableAudioPlaybackTranscoding = $("#chkEnableAudioPlaybackTranscoding", page).checked();
user.Policy.EnableVideoPlaybackTranscoding = $("#chkEnableVideoPlaybackTranscoding", page).checked();
user.Policy.EnablePlaybackRemuxing = $("#chkEnableVideoPlaybackRemuxing", page).checked();
user.Policy.EnableContentDownloading = $("#chkEnableDownloading", page).checked();
user.Policy.EnableSyncTranscoding = $("#chkEnableSyncTranscoding", page).checked();
user.Policy.EnableMediaConversion = $("#chkEnableConversion", page).checked();
user.Policy.EnablePublicSharing = $("#chkEnableSharing", page).checked();
user.Policy.EnableRemoteAccess = $("#chkRemoteAccess", page).checked();
user.Policy.RemoteClientBitrateLimit = parseInt(1e6 * parseFloat($("#txtRemoteClientBitrateLimit", page).val() || "0"));
user.Policy.LoginAttemptsBeforeLockout = parseInt($("#txtLoginAttemptsBeforeLockout", page).val() || "0");
user.Policy.AuthenticationProviderId = page.querySelector(".selectLoginProvider").value;
user.Policy.EnableContentDeletion = $("#chkEnableDeleteAllFolders", page).checked();
user.Policy.EnableContentDeletionFromFolders = user.Policy.EnableContentDeletion ? [] : $(".chkFolder", page).get().filter(function(c) {
return c.checked
}).map(function(c) {
return c.getAttribute("data-id")
}), ApiClient.updateUser(user).then(function() {
});
ApiClient.updateUser(user).then(function() {
ApiClient.updateUserPolicy(user.Id, user.Policy).then(function() {
onSaveComplete(page, user)
})

View File

@ -858,6 +858,7 @@
"LabelUserAgent": "User agent:",
"LabelUserLibrary": "User library:",
"LabelUserLibraryHelp": "Select which user library to display to the device. Leave empty to inherit the default setting.",
"LabelUserLoginAttemptsBeforeLockout": "Failed login attempts before user is locked out:",
"LabelUserRemoteClientBitrateLimitHelp": "This will override the default global value set in server playback settings.",
"LabelUsername": "Username:",
"LabelVaapiDevice": "VA API Device:",
@ -1109,6 +1110,8 @@
"OptionIsHD": "HD",
"OptionIsSD": "SD",
"OptionLikes": "Likes",
"OptionLoginAttemptsBeforeLockout": "Determines how many incorrect login attempts can be made before lockout occurs.",
"OptionLoginAttemptsBeforeLockoutHelp": "0 means inheriting the default of 3 for non-admin and 5 for admin, -1 disables lockout",
"OptionMax": "Max",
"OptionMissingEpisode": "Missing Episodes",
"OptionMonday": "Monday",

View File

@ -162,6 +162,14 @@
<div class="fieldDescription checkboxFieldDescription">${OptionHideUserFromLoginHelp}</div>
</div>
<br/>
<div class=verticalSection>
<div class="inputContainer" id="fldLoginAttemptsBeforeLockout">
<input is="emby-input" type="number" id="txtLoginAttemptsBeforeLockout" min="-1" step="1" label="${LabelUserLoginAttemptsBeforeLockout}"/>
<div class="fieldDescription">${OptionLoginAttemptsBeforeLockout}</div>
<div class="fieldDescription">${OptionLoginAttemptsBeforeLockoutHelp}</div>
</div>
</div>
<br />
<div>
<button is="emby-button" type="submit" class="raised button-submit block">
<span>${ButtonSave}</span>