mirror of https://github.com/bastienwirtz/homer
Do not mandate the usage of an API key for Pi-hole v6
parent
517de68e74
commit
7c27ae03ad
|
@ -116,14 +116,6 @@ export default {
|
||||||
this.sessionExpiry = null;
|
this.sessionExpiry = null;
|
||||||
},
|
},
|
||||||
authenticate: async function () {
|
authenticate: async function () {
|
||||||
if (!this.item.apikey) {
|
|
||||||
this.handleError(
|
|
||||||
"API key is required for PiHole authentication",
|
|
||||||
"disabled",
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const authResponse = await this.fetch("/api/auth", {
|
const authResponse = await this.fetch("/api/auth", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -166,7 +158,7 @@ export default {
|
||||||
},
|
},
|
||||||
fetchStatus: async function () {
|
fetchStatus: async function () {
|
||||||
try {
|
try {
|
||||||
if (!this.isAuthenticated) {
|
if (!this.isAuthenticated && this.item.apikey) {
|
||||||
const authenticated = await this.authenticate();
|
const authenticated = await this.authenticate();
|
||||||
if (!authenticated) return;
|
if (!authenticated) return;
|
||||||
}
|
}
|
||||||
|
@ -182,10 +174,8 @@ export default {
|
||||||
this.percent_blocked = response.queries.percent_blocked;
|
this.percent_blocked = response.queries.percent_blocked;
|
||||||
this.retryCount = 0;
|
this.retryCount = 0;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (
|
const isAuthError = e.message.includes("401 error") || e.message.includes("403 error");
|
||||||
e.message.includes("401 error") ||
|
if (isAuthError && this.item.apikey) {
|
||||||
e.message.includes("403 error")
|
|
||||||
) {
|
|
||||||
this.removeCacheSession();
|
this.removeCacheSession();
|
||||||
return this.retryWithDelay();
|
return this.retryWithDelay();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue