add optional password field on user creation

This commit is contained in:
dkanada 2019-06-30 01:52:57 -07:00
parent 24250cb4b0
commit 2609bda89d
3 changed files with 17 additions and 18 deletions

View File

@ -1190,15 +1190,13 @@ define(["events", "appStorage"], function(events, appStorage) {
data: JSON.stringify(info),
contentType: "application/json"
})
}, ApiClient.prototype.createUser = function(name) {
}, ApiClient.prototype.createUser = function(user) {
var url = this.getUrl("Users/New");
return this.ajax({
type: "POST",
url: url,
data: {
Name: name
},
dataType: "json"
data: JSON.stringify(user),
contentType: "application/json"
})
}, ApiClient.prototype.updateUser = function(user) {
if (!user) throw new Error("null user");

View File

@ -29,7 +29,8 @@ define(["jQuery", "loading", "fnchecked", "emby-checkbox"], function($, loading)
}
function loadUser(page) {
$("#txtUserName", page).val("");
$("#txtUsername", page).val("");
$("#txtPassword", page).val("");
loading.show();
var promiseFolders = ApiClient.getJSON(ApiClient.getUrl("Library/MediaFolders", {
IsHidden: false
@ -43,8 +44,10 @@ define(["jQuery", "loading", "fnchecked", "emby-checkbox"], function($, loading)
}
function saveUser(page) {
var name = $("#txtUserName", page).val();
ApiClient.createUser(name).then(function(user) {
var user = {};
user.Name = $("#txtUsername", page).val();
user.Password = $("#txtPassword", page).val();
ApiClient.createUser(user).then(function(user) {
user.Policy.EnableAllFolders = $("#chkEnableAllFolders", page).checked();
user.Policy.EnabledFolders = user.Policy.EnableAllFolders ? [] : $(".chkFolder", page).get().filter(function(i) {
return i.checked
@ -61,15 +64,9 @@ define(["jQuery", "loading", "fnchecked", "emby-checkbox"], function($, loading)
Dashboard.navigate("useredit.html?userId=" + user.Id);
});
}, function(response) {
if (response.status == 400) {
Dashboard.alert({
message: page.querySelector(".labelNewUserNameHelp").innerHTML
});
} else {
require(["toast"], function(toast) {
toast(Globalize.translate("DefaultErrorMessage"));
});
}
loading.hide();
});
}

View File

@ -9,7 +9,11 @@
</div>
<div class="inputContainer">
<input is="emby-input" id="txtUserName" required type="text" label="${LabelName}" />
<input is="emby-input" id="txtUsername" required type="text" label="${LabelName}" />
</div>
<div class="inputContainer">
<input is="emby-input" id="txtPassword" type="password" label="${LabelPassword}" />
</div>
</div>