Skip to content

Commit

Permalink
Added dropdown for authentication methods
Browse files Browse the repository at this point in the history
  • Loading branch information
sharknoon committed Mar 21, 2023
1 parent 442f54d commit 35a56dd
Show file tree
Hide file tree
Showing 5 changed files with 2,213 additions and 2,192 deletions.
4 changes: 2 additions & 2 deletions server/notification-providers/ntfy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class Ntfy extends NotificationProvider {
let okMsg = "Sent Successfully.";
try {
let headers = {};
if (notification.ntfyusername) {
if (notification.ntfyAuthenticationMethod === "usernamePassword") {
headers = {
"Authorization": "Basic " + Buffer.from(notification.ntfyusername + ":" + notification.ntfypassword).toString("base64"),
};
} else if (notification.ntfyaccesstoken) {
} else if (notification.ntfyAuthenticationMethod === "accessToken") {
headers = {
"Authorization": "Bearer " + notification.ntfyaccesstoken,
};
Expand Down
25 changes: 20 additions & 5 deletions src/components/notifications/Ntfy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,25 @@
<input id="ntfy-priority" v-model="$parent.notification.ntfyPriority" type="number" class="form-control" required min="1" max="5" step="1">
</div>
<div class="mb-3">
<label for="ntfy-username" class="form-label">{{ $t("Username") }} ({{ $t("Optional") }})</label>
<label for="authentication-method" class="form-label">{{ $t("AuthenticationMethod") }}</label>
<select id="authentication-method" v-model="$parent.notification.ntfyAuthenticationMethod" class="form-select">
<option v-for="(name, type) in authenticationMethods" :key="type" :value="type">{{ name }}</option>
</select>
</div>
<div class="mb-3" v-if="$parent.notification.ntfyAuthenticationMethod === 'usernamePassword'">
<label for="ntfy-username" class="form-label">{{ $t("Username") }}</label>
<div class="input-group mb-3">
<input id="ntfy-username" v-model="$parent.notification.ntfyusername" type="text" class="form-control">
</div>
</div>
<div class="mb-3">
<label for="ntfy-password" class="form-label">{{ $t("Password") }} ({{ $t("Optional") }})</label>
<div class="mb-3" v-if="$parent.notification.ntfyAuthenticationMethod === 'usernamePassword'">
<label for="ntfy-password" class="form-label">{{ $t("Password") }}</label>
<div class="input-group mb-3">
<HiddenInput id="ntfy-password" v-model="$parent.notification.ntfypassword" autocomplete="new-password"></HiddenInput>
</div>
</div>
<div class="mb-3">
<label for="ntfy-access-token" class="form-label">{{ $t("Access Token") }} ({{ $t("Optional") }})</label>
<div class="mb-3" v-if="$parent.notification.ntfyAuthenticationMethod === 'accessToken'">
<label for="ntfy-access-token" class="form-label">{{ $t("Access Token") }}</label>
<div class="input-group mb-3">
<HiddenInput id="ntfy-access-token" v-model="$parent.notification.ntfyaccesstoken"></HiddenInput>
</div>
Expand All @@ -46,6 +52,15 @@ export default {
components: {
HiddenInput,
},
computed: {
authenticationMethods() {
return {
none: this.$t("None"),
usernamePassword: this.$t("UsernameAndPassword"),
accessToken: this.$t("Access Token")
}
}
},
mounted() {
if (typeof this.$parent.notification.ntfyPriority === "undefined") {
this.$parent.notification.ntfyserverurl = "https://ntfy.sh";
Expand Down
Loading

0 comments on commit 35a56dd

Please sign in to comment.