mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-09-14 10:52:34 +00:00
Fix proxy hosts routes throwing errors
This commit is contained in:
@@ -420,10 +420,9 @@ const internalProxyHost = {
|
|||||||
* @param {String} [search_query]
|
* @param {String} [search_query]
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
getAll: (access, expand, search_query) => {
|
getAll: async (access, expand, searchQuery) => {
|
||||||
return access
|
const accessData = await access.can("proxy_hosts:list");
|
||||||
.can("proxy_hosts:list")
|
|
||||||
.then((access_data) => {
|
|
||||||
const query = proxyHostModel
|
const query = proxyHostModel
|
||||||
.query()
|
.query()
|
||||||
.where("is_deleted", 0)
|
.where("is_deleted", 0)
|
||||||
@@ -431,14 +430,14 @@ const internalProxyHost = {
|
|||||||
.allowGraph("[owner,access_list,certificate]")
|
.allowGraph("[owner,access_list,certificate]")
|
||||||
.orderBy(castJsonIfNeed("domain_names"), "ASC");
|
.orderBy(castJsonIfNeed("domain_names"), "ASC");
|
||||||
|
|
||||||
if (access_data.permission_visibility !== "all") {
|
if (accessData.permission_visibility !== "all") {
|
||||||
query.andWhere("owner_user_id", access.token.getUserId(1));
|
query.andWhere("owner_user_id", access.token.getUserId(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query is used for searching
|
// Query is used for searching
|
||||||
if (typeof search_query === "string" && search_query.length > 0) {
|
if (typeof searchQuery === "string" && searchQuery.length > 0) {
|
||||||
query.where(function () {
|
query.where(function () {
|
||||||
this.where(castJsonIfNeed("domain_names"), "like", `%${search_query}%`);
|
this.where(castJsonIfNeed("domain_names"), "like", `%${searchQuery}%`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,15 +445,13 @@ const internalProxyHost = {
|
|||||||
query.withGraphFetched(`[${expand.join(", ")}]`);
|
query.withGraphFetched(`[${expand.join(", ")}]`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return query.then(utils.omitRows(omissions()));
|
const rows = await query.then(utils.omitRows(omissions()));
|
||||||
})
|
|
||||||
.then((rows) => {
|
|
||||||
if (typeof expand !== "undefined" && expand !== null && expand.indexOf("certificate") !== -1) {
|
if (typeof expand !== "undefined" && expand !== null && expand.indexOf("certificate") !== -1) {
|
||||||
return internalHost.cleanAllRowsCertificateMeta(rows);
|
return internalHost.cleanAllRowsCertificateMeta(rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rows;
|
return rows;
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -107,7 +107,6 @@ export default function (tokenString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tokenUserId = tokenData.attrs.id ? tokenData.attrs.id : 0;
|
const tokenUserId = tokenData.attrs.id ? tokenData.attrs.id : 0;
|
||||||
let query;
|
|
||||||
|
|
||||||
if (typeof objectCache[objectType] !== "undefined") {
|
if (typeof objectCache[objectType] !== "undefined") {
|
||||||
objects = objectCache[objectType];
|
objects = objectCache[objectType];
|
||||||
@@ -120,12 +119,16 @@ export default function (tokenString) {
|
|||||||
|
|
||||||
// Proxy Hosts
|
// Proxy Hosts
|
||||||
case "proxy_hosts": {
|
case "proxy_hosts": {
|
||||||
query = proxyHostModel.query().select("id").andWhere("is_deleted", 0);
|
const query = proxyHostModel
|
||||||
|
.query()
|
||||||
|
.select("id")
|
||||||
|
.andWhere("is_deleted", 0);
|
||||||
|
|
||||||
if (permissions.visibility === "user") {
|
if (permissions.visibility === "user") {
|
||||||
query.andWhere("owner_user_id", tokenUserId);
|
query.andWhere("owner_user_id", tokenUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rows = await query();
|
const rows = await query;
|
||||||
objects = [];
|
objects = [];
|
||||||
_.forEach(rows, (ruleRow) => {
|
_.forEach(rows, (ruleRow) => {
|
||||||
result.push(ruleRow.id);
|
result.push(ruleRow.id);
|
||||||
@@ -141,7 +144,6 @@ export default function (tokenString) {
|
|||||||
objectCache[objectType] = objects;
|
objectCache[objectType] = objects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return objects;
|
return objects;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -3,5 +3,5 @@
|
|||||||
"ignore": [
|
"ignore": [
|
||||||
"data"
|
"data"
|
||||||
],
|
],
|
||||||
"ext": "js json ejs"
|
"ext": "js json ejs cjs"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user