diff --git a/ApiClient.js b/ApiClient.js index a90d2dcf8b..4a0222139d 100644 --- a/ApiClient.js +++ b/ApiClient.js @@ -1432,9 +1432,9 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { /** * Gets all users from the server */ - self.getUsers = function () { + self.getUsers = function (options) { - var url = self.getUrl("users"); + var url = self.getUrl("users", options || {}); return self.ajax({ type: "GET", @@ -1870,6 +1870,32 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { return files; }; + /** + * Authenticates a user + * @param {String} name + * @param {String} password + */ + self.authenticateUserByName = function (name, password) { + + if (!name) { + throw new Error("null name"); + } + + var url = self.getUrl("Users/" + name + "/authenticatebyname"); + + var postData = { + password: MediaBrowser.SHA1(password || "") + }; + + return self.ajax({ + type: "POST", + url: url, + data: JSON.stringify(postData), + dataType: "json", + contentType: "application/json" + }); + }; + /** * Authenticates a user * @param {String} userId @@ -1891,6 +1917,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { type: "POST", url: url, data: JSON.stringify(postData), + dataType: "json", contentType: "application/json" }); }; diff --git a/dashboard-ui/allusersettings.html b/dashboard-ui/allusersettings.html new file mode 100644 index 0000000000..40e856f3dc --- /dev/null +++ b/dashboard-ui/allusersettings.html @@ -0,0 +1,51 @@ + + + + User Profiles + + +
+ +
+
+
+ Users + Settings +
+ + +
+ +

Require manual username entry for:

+
+ + + + + + +
+
This will be ignored on localhost
+
+
+ +
    +
  • + + +
  • +
+ +
+
+
+ +
+ + diff --git a/dashboard-ui/dashboard.html b/dashboard-ui/dashboard.html index d46d273454..7d1c38c2f6 100644 --- a/dashboard-ui/dashboard.html +++ b/dashboard-ui/dashboard.html @@ -68,7 +68,7 @@ - Become a Developer + Become a Developer diff --git a/dashboard-ui/edituser.html b/dashboard-ui/edituser.html index ff1af51531..90924a3ccf 100644 --- a/dashboard-ui/edituser.html +++ b/dashboard-ui/edituser.html @@ -12,7 +12,7 @@ Profile Image Password - +
+ - \ No newline at end of file + diff --git a/dashboard-ui/login.html b/dashboard-ui/login.html index 4b649d997b..7ae2ecd6c6 100644 --- a/dashboard-ui/login.html +++ b/dashboard-ui/login.html @@ -7,11 +7,28 @@
-
+ + +

Please sign in

+ + + + + + + +

+ +

+ + +
diff --git a/dashboard-ui/scripts/allusersettings.js b/dashboard-ui/scripts/allusersettings.js new file mode 100644 index 0000000000..af13aec697 --- /dev/null +++ b/dashboard-ui/scripts/allusersettings.js @@ -0,0 +1,68 @@ +(function ($, document, window) { + + function loadPage(page, config) { + + var clients = config.ManualLoginClients; + + $('#chkMobileClients', page).checked(clients.filter(function (i) { + + return i == "Mobile"; + + }).length > 0).checkboxradio("refresh"); + + $('#chkMBT', page).checked(clients.filter(function (i) { + + return i == "MediaBrowserTheater"; + + }).length > 0).checkboxradio("refresh"); + + Dashboard.hideLoadingMsg(); + } + + $(document).on('pageshow', "#allUserSettingsPage", function () { + + Dashboard.showLoadingMsg(); + + var page = this; + + ApiClient.getServerConfiguration().done(function (config) { + + loadPage(page, config); + + }); + }); + + function allUserSettingsPage() { + + var self = this; + + self.onSubmit = function () { + Dashboard.showLoadingMsg(); + + var form = this; + + ApiClient.getServerConfiguration().done(function (config) { + + var clients = []; + + if ($('#chkMobileClients', form).checked()) { + clients.push("Mobile"); + } + + if ($('#chkMBT', form).checked()) { + clients.push("MediaBrowserTheater"); + } + + config.ManualLoginClients = clients; + + ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult); + }); + + // Disable default form submission + return false; + }; + } + + window.AllUserSettingsPage = new allUserSettingsPage(); + +})(jQuery, document, window); diff --git a/dashboard-ui/scripts/edituserpage.js b/dashboard-ui/scripts/edituserpage.js index 3d09a89c42..eba75b8a48 100644 --- a/dashboard-ui/scripts/edituserpage.js +++ b/dashboard-ui/scripts/edituserpage.js @@ -59,8 +59,10 @@ if (!loggedInUser.Configuration.IsAdministrator) { $('#parentalControlDiv', page).hide(); $('#fldIsAdmin', page).hide(); + $('#accessControlDiv', page).show(); } else { $('#parentalControlDiv', page).show(); + $('#accessControlDiv', page).show(); $('#fldIsAdmin', page).show(); } @@ -102,6 +104,9 @@ $('#chkIsAdmin', page).checked(user.Configuration.IsAdministrator || false).checkboxradio("refresh"); $('#chkBlockNotRated', page).checked(user.Configuration.BlockNotRated || false).checkboxradio("refresh"); + $('#chkDisabled', page).checked(user.Configuration.IsDisabled || false).checkboxradio("refresh"); + $('#chkIsHidden', page).checked(user.Configuration.IsHidden || false).checkboxradio("refresh"); + Dashboard.hideLoadingMsg(); } @@ -132,6 +137,9 @@ user.Configuration.UseForcedSubtitlesOnly = $('#chkForcedSubtitlesOnly', page).checked(); user.Configuration.BlockNotRated = $('#chkBlockNotRated', page).checked(); + user.Configuration.IsHidden = $('#chkIsHidden', page).checked(); + user.Configuration.IsDisabled = $('#chkDisabled', page).checked(); + var userId = getParameterByName("userId"); if (userId) { diff --git a/dashboard-ui/scripts/loginpage.js b/dashboard-ui/scripts/loginpage.js index cfaa9b0cdb..5b01a0f06a 100644 --- a/dashboard-ui/scripts/loginpage.js +++ b/dashboard-ui/scripts/loginpage.js @@ -3,7 +3,37 @@ onPageShow: function () { Dashboard.showLoadingMsg(); - ApiClient.getUsers().done(LoginPage.loadUserList); + var promise1 = ApiClient.getUsers({ IsHidden: false }); + var promise2 = ApiClient.getServerConfiguration(); + + $.when(promise1, promise2).done(function (response1, response2) { + + var users = response1[0]; + var config = response2[0]; + + var showManualForm = config.ManualLoginClients.filter(function (i) { + + return i == "Mobile"; + + }).length || !users.length; + + showManualForm &= window.location.toString().toLowerCase().indexOf('localhost') == -1; + + if (showManualForm) { + + $('#divUsers', '#loginPage').hide(); + $('#manualLoginForm', '#loginPage').show(); + + } else { + + $('#divUsers', '#loginPage').show(); + $('#manualLoginForm', '#loginPage').hide(); + + LoginPage.loadUserList(users); + } + + Dashboard.hideLoadingMsg(); + }); }, getLastSeenText: function (lastActivityDate) { @@ -33,17 +63,20 @@ LoginPage.authenticateUser(link.getAttribute('data-username'), link.getAttribute('data-userid')); }, - authenticateUser: function (username, userId, password) { + authenticateUser: function (username, password) { Dashboard.showLoadingMsg(); - ApiClient.authenticateUser(userId, password).done(function () { + ApiClient.authenticateUserByName(username, password).done(function (result) { - Dashboard.setCurrentUser(userId); + Dashboard.setCurrentUser(result.User.Id); - window.location = "index.html?u=" + userId; + window.location = "index.html?u=" + result.User.Id; }).fail(function () { + + $('#pw', '#loginPage').val(''); + Dashboard.hideLoadingMsg(); setTimeout(function () { @@ -61,9 +94,9 @@ var linkId = "lnkUser" + i; if (user.HasPassword) { - html += ""; + html += ""; } else { - html += ""; + html += ""; } if (user.PrimaryImageTag) { @@ -100,15 +133,23 @@ $('#divUsers', '#loginPage').html(html); - Dashboard.hideLoadingMsg(); }, onSubmit: function () { + $('#popupLogin', '#loginPage').popup('close'); var link = $('#' + LoginPage.authenticatingLinkId)[0]; - LoginPage.authenticateUser(link.getAttribute('data-username'), link.getAttribute('data-userid'), $('#pw', '#loginPage').val()); + LoginPage.authenticateUser(link.getAttribute('data-username'), $('#pw', '#loginPage').val()); + + // Disable default form submission + return false; + }, + + onManualSubmit: function () { + + LoginPage.authenticateUser($('#txtManualName', '#loginPage').val(), $('#txtManualPassword', '#loginPage').val()); // Disable default form submission return false; diff --git a/dashboard-ui/userprofiles.html b/dashboard-ui/userprofiles.html index 4fb1204de3..7a90a7275d 100644 --- a/dashboard-ui/userprofiles.html +++ b/dashboard-ui/userprofiles.html @@ -8,6 +8,12 @@
+ + +