Skip to content

Commit abb0cf8

Browse files
tanasegabrielbastienwirtz
authored andcommitted
Do not mandate the usage of an API key for Pi-hole v6
1 parent 517de68 commit abb0cf8

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/components/services/PiHole.vue

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,6 @@ export default {
116116
this.sessionExpiry = null;
117117
},
118118
authenticate: async function () {
119-
if (!this.item.apikey) {
120-
this.handleError(
121-
"API key is required for PiHole authentication",
122-
"disabled",
123-
);
124-
return false;
125-
}
126-
127119
try {
128120
const authResponse = await this.fetch("/api/auth", {
129121
method: "POST",
@@ -166,7 +158,7 @@ export default {
166158
},
167159
fetchStatus: async function () {
168160
try {
169-
if (!this.isAuthenticated) {
161+
if (!this.isAuthenticated && this.item.apikey) {
170162
const authenticated = await this.authenticate();
171163
if (!authenticated) return;
172164
}
@@ -182,10 +174,8 @@ export default {
182174
this.percent_blocked = response.queries.percent_blocked;
183175
this.retryCount = 0;
184176
} catch (e) {
185-
if (
186-
e.message.includes("401 error") ||
187-
e.message.includes("403 error")
188-
) {
177+
const isAuthError = e.message.includes("401 error") || e.message.includes("403 error");
178+
if (isAuthError && this.item.apikey) {
189179
this.removeCacheSession();
190180
return this.retryWithDelay();
191181
}

0 commit comments

Comments
 (0)