Merge pull request #4280 from hellomouse/restrict-notifs-to-https

Add warning for HTTPS requirement on notifications
This commit is contained in:
Max Leiter 2021-07-06 00:58:50 -07:00 committed by GitHub
commit 18b003db9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -306,6 +306,7 @@
<input <input
id="desktopNotifications" id="desktopNotifications"
:checked="$store.state.settings.desktopNotifications" :checked="$store.state.settings.desktopNotifications"
:disabled="$store.state.desktopNotificationState === 'nohttps'"
type="checkbox" type="checkbox"
name="desktopNotifications" name="desktopNotifications"
/> />
@ -316,6 +317,14 @@
> >
<strong>Warning</strong>: Notifications are not supported by your browser. <strong>Warning</strong>: Notifications are not supported by your browser.
</div> </div>
<div
v-if="$store.state.desktopNotificationState === 'nohttps'"
id="warnBlockedDesktopNotifications"
class="error"
>
<strong>Warning</strong>: Notifications are only supported over HTTPS
connections.
</div>
<div <div
v-if="$store.state.desktopNotificationState === 'blocked'" v-if="$store.state.desktopNotificationState === 'blocked'"
id="warnBlockedDesktopNotifications" id="warnBlockedDesktopNotifications"

View File

@ -12,6 +12,8 @@ function detectDesktopNotificationState() {
return "unsupported"; return "unsupported";
} else if (Notification.permission === "granted") { } else if (Notification.permission === "granted") {
return "granted"; return "granted";
} else if (!window.isSecureContext) {
return "nohttps";
} }
return "blocked"; return "blocked";