Minor refactor - change variable names and add commas to object definitions

This commit is contained in:
Ivan Bratović 2021-11-04 10:12:06 +01:00
parent 0dcb7aed21
commit 179ca232bc
5 changed files with 16 additions and 16 deletions

View File

@ -2,9 +2,9 @@
BEGIN TRANSACTION; BEGIN TRANSACTION;
ALTER TABLE monitor ALTER TABLE monitor
ADD basicauth_user TEXT default null; ADD basic_auth_user TEXT default null;
ALTER TABLE monitor ALTER TABLE monitor
ADD basicauth_pass TEXT default null; ADD basic_auth_pass TEXT default null;
COMMIT; COMMIT;

View File

@ -52,7 +52,7 @@ class Database {
"patch-http-monitor-method-body-and-headers.sql": true, "patch-http-monitor-method-body-and-headers.sql": true,
"patch-2fa-invalidate-used-token.sql": true, "patch-2fa-invalidate-used-token.sql": true,
"patch-notification_sent_history.sql": true, "patch-notification_sent_history.sql": true,
"patch-monitor-basicauth.sql": true, "patch-monitor-basic-auth.sql": true,
} }
/** /**

View File

@ -58,8 +58,8 @@ class Monitor extends BeanModel {
method: this.method, method: this.method,
body: this.body, body: this.body,
headers: this.headers, headers: this.headers,
basicauth_user: this.basicauth_user, basic_auth_user: this.basic_auth_user,
basicauth_pass: this.basicauth_pass, basic_auth_pass: this.basic_auth_pass,
hostname: this.hostname, hostname: this.hostname,
port: this.port, port: this.port,
maxretries: this.maxretries, maxretries: this.maxretries,
@ -153,10 +153,10 @@ class Monitor extends BeanModel {
let startTime = dayjs().valueOf(); let startTime = dayjs().valueOf();
// HTTP basic auth // HTTP basic auth
let basicauthHeader = {}; let basicAuthHeader = {};
if (this.basicauth_user) { if (this.basic_auth_user) {
basicauthHeader = { basicAuthHeader = {
"Authorization": "Basic " + this.encodeB64(this.basicauth_user, this.basicauth_pass) "Authorization": "Basic " + this.encodeB64(this.basic_auth_user, this.basic_auth_pass),
}; };
} }
@ -169,7 +169,7 @@ class Monitor extends BeanModel {
"Accept": "*/*", "Accept": "*/*",
"User-Agent": "Uptime-Kuma/" + version, "User-Agent": "Uptime-Kuma/" + version,
...(this.headers ? JSON.parse(this.headers) : {}), ...(this.headers ? JSON.parse(this.headers) : {}),
...(basicauthHeader) ...(basicAuthHeader),
}, },
httpsAgent: new https.Agent({ httpsAgent: new https.Agent({
maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940) maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940)

View File

@ -575,8 +575,8 @@ exports.entryPage = "dashboard";
bean.method = monitor.method; bean.method = monitor.method;
bean.body = monitor.body; bean.body = monitor.body;
bean.headers = monitor.headers; bean.headers = monitor.headers;
bean.basicauth_user = monitor.basicauth_user; bean.basic_auth_user = monitor.basic_auth_user;
bean.basicauth_pass = monitor.basicauth_pass; bean.basic_auth_pass = monitor.basic_auth_pass;
bean.interval = monitor.interval; bean.interval = monitor.interval;
bean.retryInterval = monitor.retryInterval; bean.retryInterval = monitor.retryInterval;
bean.hostname = monitor.hostname; bean.hostname = monitor.hostname;
@ -1141,8 +1141,8 @@ exports.entryPage = "dashboard";
method: monitorListData[i].method || "GET", method: monitorListData[i].method || "GET",
body: monitorListData[i].body, body: monitorListData[i].body,
headers: monitorListData[i].headers, headers: monitorListData[i].headers,
basicauth_user: monitorListData[i].basicauth_user, basic_auth_user: monitorListData[i].basic_auth_user,
basicauth_pass: monitorListData[i].basicauth_pass, basic_auth_pass: monitorListData[i].basic_auth_pass,
interval: monitorListData[i].interval, interval: monitorListData[i].interval,
retryInterval: retryInterval, retryInterval: retryInterval,
hostname: monitorListData[i].hostname, hostname: monitorListData[i].hostname,

View File

@ -270,9 +270,9 @@
<h4 class="mt-5 mb-2">{{ $t("HTTP Basic Auth") }}</h4> <h4 class="mt-5 mb-2">{{ $t("HTTP Basic Auth") }}</h4>
<div class="my-3"> <div class="my-3">
<label for="basicauth" class="form-label">{{ $t("Username") }}</label> <label for="basicauth" class="form-label">{{ $t("Username") }}</label>
<input id="basicauth-user" v-model="monitor.basicauth_user" type="text" class="form-control" :placeholder="Username"> <input id="basicauth-user" v-model="monitor.basic_auth_user" type="text" class="form-control" :placeholder="Username">
<label for="basicauth" class="form-label">{{ $t("Password") }}</label> <label for="basicauth" class="form-label">{{ $t("Password") }}</label>
<input id="basicauth-pass" v-model="monitor.basicauth_pass" type="password" class="form-control" :placeholder="Password"> <input id="basicauth-pass" v-model="monitor.basic_auth_pass" type="password" class="form-control" :placeholder="Password">
</div> </div>
</template> </template>
</div> </div>