From 8d3027d10075957854e39b475077b36a00af024d Mon Sep 17 00:00:00 2001 From: Phallacy Date: Sat, 16 Mar 2019 00:18:17 -0700 Subject: [PATCH 1/7] added settings to support configurable lockout --- src/scripts/useredit.js | 4 ++-- src/strings/en-us.json | 3 +++ src/useredit.html | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/scripts/useredit.js b/src/scripts/useredit.js index 709b2557c1..62c9ed37c6 100644 --- a/src/scripts/useredit.js +++ b/src/scripts/useredit.js @@ -28,7 +28,7 @@ define(["jQuery", "loading", "libraryMenu", "fnchecked"], function($, loading, l IsHidden: !1 })).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() + }), 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 || ""), $("#txtLoginAttemptsBeforeLockout", page).val(user.Policy.LoginAttemptsBeforeLockout || "0"), loading.hide() } function onSaveComplete(page, user) { @@ -40,7 +40,7 @@ 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") diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 9c0cac2a24..5e5e43f90b 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -1300,6 +1300,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 Logins before Lockout:", "LabelUserRemoteClientBitrateLimitHelp": "This will override the default global value set in server playback settings.", "LabelUsername": "Username:", "LabelVaapiDevice": "VA API Device:", @@ -1696,6 +1697,8 @@ "OptionLikes": "Likes", "OptionList": "List", "OptionLocked": "Locked", + "OptionLoginAttemptsBeforeLockout": "Determines how many incorrect password attempts can be made before lockout occurs.", + "OptionLoginAttemptsBeforeLockoutHelp":"0 inherits the old default of 3 for non admin and 5 for admin, -1 to disable lockout", "OptionLogo": "Logo", "OptionMax": "Max", "OptionMenu": "Menu", diff --git a/src/useredit.html b/src/useredit.html index 7a7fcd990c..ba1b054081 100644 --- a/src/useredit.html +++ b/src/useredit.html @@ -154,6 +154,13 @@
${OptionDisableUserHelp}
+
+ +
${OptionLoginAttemptsBeforeLockoutHelp}
+
${OptionDisableUserHelp}
-
- -
${OptionLoginAttemptsBeforeLockoutHelp}
-
${OptionHideUserFromLoginHelp}
+
+
+ +
${OptionLoginAttemptsBeforeLockout}
+
${OptionLoginAttemptsBeforeLockoutHelp}
+
+

+
- +
${OptionLoginAttemptsBeforeLockout}
${OptionLoginAttemptsBeforeLockoutHelp}
From dab41fe6e15c802509023e1ccef591601dd88a59 Mon Sep 17 00:00:00 2001 From: Phallacy Date: Sun, 17 Mar 2019 01:13:12 -0700 Subject: [PATCH 4/7] made the main save and load methods that I modified more legible --- src/scripts/useredit.js | 63 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/src/scripts/useredit.js b/src/scripts/useredit.js index 62c9ed37c6..916a09e402 100644 --- a/src/scripts/useredit.js +++ b/src/scripts/useredit.js @@ -22,13 +22,42 @@ 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", { + }), + ApiClient.getJSON(ApiClient.getUrl("Library/MediaFolders", { IsHidden: !1 })).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 || ""), $("#txtLoginAttemptsBeforeLockout", page).val(user.Policy.LoginAttemptsBeforeLockout || "0"), loading.hide() + }), + 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 || ""), + $("#txtLoginAttemptsBeforeLockout", page).val(user.Policy.LoginAttemptsBeforeLockout || "0"), + loading.hide() } function onSaveComplete(page, user) { @@ -40,11 +69,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.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 + 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) }) From 22649b66a69f167fa5e7e6a273a180deb61744d5 Mon Sep 17 00:00:00 2001 From: Vasily Date: Tue, 19 Mar 2019 23:12:23 -0700 Subject: [PATCH 5/7] Apply suggestions from JustAMan code review https://www.youtube.com/watch?v=-CmadmM5cOk Co-Authored-By: LogicalPhallacy <44458166+LogicalPhallacy@users.noreply.github.com> --- src/scripts/useredit.js | 112 ++++++++++++++++++++++------------------ src/strings/en-us.json | 6 +-- 2 files changed, 64 insertions(+), 54 deletions(-) diff --git a/src/scripts/useredit.js b/src/scripts/useredit.js index 916a09e402..74d70ac0bf 100644 --- a/src/scripts/useredit.js +++ b/src/scripts/useredit.js @@ -22,42 +22,52 @@ define(["jQuery", "loading", "libraryMenu", "fnchecked"], function($, loading, l } function loadUser(page, user) { - currentUser = user, + currentUser = user; ApiClient.getJSON(ApiClient.getUrl("Auth/Providers")).then(function(providers) { loadAuthProviders(page, user, providers) - }), + }); ApiClient.getJSON(ApiClient.getUrl("Library/MediaFolders", { - IsHidden: !1 + IsHidden: false })).then(function(folders) { loadDeleteFolders(page, user, folders.Items) - }), - user.Policy.IsDisabled ? $(".disabledUserBanner", page).show() : $(".disabledUserBanner", page).hide(), + }); + if (user.Policy.IsDisabled) { + $(".disabledUserBanner", page).show(); + } else { + $(".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 || ""), - $("#txtLoginAttemptsBeforeLockout", page).val(user.Policy.LoginAttemptsBeforeLockout || "0"), - loading.hide() + if ("Guest" == user.ConnectLinkType) { + $("#fldConnectInfo", page).hide(); + $("#txtUserName", page).prop("disabled", "disabled"); + } else { + $("#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) { @@ -69,32 +79,32 @@ 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.LoginAttemptsBeforeLockout = parseInt($("#txtLoginAttemptsBeforeLockout", page).val() || "0"), - user.Policy.AuthenticationProviderId = page.querySelector(".selectLoginProvider").value, - user.Policy.EnableContentDeletion = $("#chkEnableDeleteAllFolders", page).checked(), + 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.updateUserPolicy(user.Id, user.Policy).then(function() { onSaveComplete(page, user) diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 5e5e43f90b..a76e496623 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -1300,7 +1300,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 Logins before Lockout:", + "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:", @@ -1697,8 +1697,8 @@ "OptionLikes": "Likes", "OptionList": "List", "OptionLocked": "Locked", - "OptionLoginAttemptsBeforeLockout": "Determines how many incorrect password attempts can be made before lockout occurs.", - "OptionLoginAttemptsBeforeLockoutHelp":"0 inherits the old default of 3 for non admin and 5 for admin, -1 to disable lockout", + "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", "OptionLogo": "Logo", "OptionMax": "Max", "OptionMenu": "Menu", From 4144d929e7d02cfd1380edeaae72f5297ab33e91 Mon Sep 17 00:00:00 2001 From: Vasily Date: Sat, 23 Mar 2019 23:47:31 -0700 Subject: [PATCH 6/7] Apply suggestions from code review adding justaman's fixes Co-Authored-By: LogicalPhallacy <44458166+LogicalPhallacy@users.noreply.github.com> --- src/scripts/useredit.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/scripts/useredit.js b/src/scripts/useredit.js index 74d70ac0bf..e972627c88 100644 --- a/src/scripts/useredit.js +++ b/src/scripts/useredit.js @@ -36,8 +36,6 @@ define(["jQuery", "loading", "libraryMenu", "fnchecked"], function($, loading, l } else { $(".disabledUserBanner", page).hide(); } - "Guest" == user.ConnectLinkType ? ($("#fldConnectInfo", page).hide(), - $("#txtUserName", page).prop("disabled", "disabled")) : ($("#txtUserName", page).prop("disabled", "").removeAttr("disabled"), if ("Guest" == user.ConnectLinkType) { $("#fldConnectInfo", page).hide(); $("#txtUserName", page).prop("disabled", "disabled"); From 0fe1d350e6b15170086a3269530a37b7f4bacf27 Mon Sep 17 00:00:00 2001 From: Phallacy Date: Mon, 25 Mar 2019 00:30:45 -0700 Subject: [PATCH 7/7] removes useless connectlinktype check --- src/scripts/useredit.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/scripts/useredit.js b/src/scripts/useredit.js index e972627c88..7c355078c0 100644 --- a/src/scripts/useredit.js +++ b/src/scripts/useredit.js @@ -36,13 +36,8 @@ define(["jQuery", "loading", "libraryMenu", "fnchecked"], function($, loading, l } else { $(".disabledUserBanner", page).hide(); } - if ("Guest" == user.ConnectLinkType) { - $("#fldConnectInfo", page).hide(); - $("#txtUserName", page).prop("disabled", "disabled"); - } else { - $("#txtUserName", page).prop("disabled", "").removeAttr("disabled"); - $("#fldConnectInfo", page).show(); - } + $("#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;