|
|
@@ -15,8 +15,11 @@ function closeLoginPopin() {
|
|
|
document.body.classList.remove("login-visible");
|
|
|
document.body.classList.remove("overlay-visible");
|
|
|
let inputFields = document.querySelectorAll(".login-wrapper .input-group input");
|
|
|
- for (let i =0; i < inputFields.length; ++i)
|
|
|
- inputFields[i].value = "";
|
|
|
+ for (let i =0; i < inputFields.length; ++i) {
|
|
|
+ if (inputFields[i].type !== 'submit')
|
|
|
+ inputFields[i].value = "";
|
|
|
+ }
|
|
|
+ document.querySelector("#login-userpass + .error").classList.add("hidden");
|
|
|
}
|
|
|
|
|
|
document.onClosePopinRequested(() => {
|
|
|
@@ -28,10 +31,23 @@ document.querySelector(".login-wrapper .modal-footer button").addEventListener("
|
|
|
let loginUserPass = document.getElementById("login-userpass");
|
|
|
let loginCode = document.getElementById("login-code");
|
|
|
|
|
|
-loginUserPass.querySelector("button").addEventListener("click", () => {
|
|
|
+loginUserPass.parentElement.addEventListener("submit", e => {
|
|
|
+ e.preventDefault();
|
|
|
let user = loginUserPass.querySelector("input[type='text']").value;
|
|
|
let pass = loginUserPass.querySelector("input[type='password']").value;
|
|
|
- console.log([user, pass]);
|
|
|
+ LoadingTasks.push(async () => {
|
|
|
+ try {
|
|
|
+ await AccessManager.LoginUserPass(user, pass);
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ let errDiv = loginUserPass.parentElement.querySelector(".error");
|
|
|
+ errDiv.textContent = err;
|
|
|
+ errDiv.classList.remove("hidden");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ await MediaStorage.Instance.rebuildMetaList();
|
|
|
+ closeLoginPopin();
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
loginCode.querySelector("button").addEventListener("click", () => {
|
|
|
@@ -45,7 +61,7 @@ loginCode.querySelector("button").addEventListener("click", () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
-async function logout(accessId, linkId) {
|
|
|
+async function logout(accessId) {
|
|
|
await AccessManager.Logout(accessId);
|
|
|
await MediaStorage.Instance.rebuildMetaList();
|
|
|
closeLoginPopin();
|
|
|
@@ -63,6 +79,7 @@ window.ReloadAccessList = function(accessList) {
|
|
|
}
|
|
|
|
|
|
let getIconForType = type => {
|
|
|
+ if (!!type.ldapDn) return "bi-database";
|
|
|
if (!!type.linkId) return "bi-link-45deg";
|
|
|
if (!!type.userName) return "bi-person";
|
|
|
return "bi-question-octagon";
|
|
|
@@ -73,6 +90,7 @@ window.ReloadAccessList = function(accessList) {
|
|
|
for (let i =0; i < items.length; ++i)
|
|
|
items[i].remove();
|
|
|
delete accessList.isAdmin;
|
|
|
+ delete accessList.isAdmin_;
|
|
|
if (Object.keys(accessList||{}).length) {
|
|
|
let li = document.createElement("li");
|
|
|
li.classList.add("accessItem");
|
|
|
@@ -83,7 +101,7 @@ window.ReloadAccessList = function(accessList) {
|
|
|
rootNode.appendChild(li);
|
|
|
}
|
|
|
for (let i in accessList) {
|
|
|
- const accessTextValue = accessList[i].linkLabel || accessList[i].linkId;
|
|
|
+ const accessTextValue = accessList[i].linkLabel || accessList[i].linkId || accessList[i].ldapDn;
|
|
|
|
|
|
let li = document.createElement("li");
|
|
|
li.classList.add("accessItem");
|
|
|
@@ -102,11 +120,11 @@ window.ReloadAccessList = function(accessList) {
|
|
|
a.appendChild(logoutIcon);
|
|
|
li.appendChild(a);
|
|
|
rootNode.appendChild(li);
|
|
|
- a.addEventListener("click", e => {
|
|
|
+ a.addEventListener("click", async e => {
|
|
|
e.preventDefault();
|
|
|
- if (!window.confirm("Logout account " +accessTextValue +" ?"))
|
|
|
+ if (!await window.confirm("Logout account " +accessTextValue +" ?"))
|
|
|
return;
|
|
|
- logout(i, accessList[i].linkId);
|
|
|
+ logout(i);
|
|
|
});
|
|
|
}
|
|
|
}
|