diff --git a/app.py b/app.py index 11e0d28..fc2990e 100644 --- a/app.py +++ b/app.py @@ -159,7 +159,7 @@ def login() -> Union[Response, str]: next_url = request.args.get("next") if next_url: return redirect(next_url) - return redirect(url_for("home")) + return redirect(url_for("home", loggedin=True)) except requests.exceptions.RequestException: pass # Fall through to error diff --git a/templates/base.html b/templates/base.html index ee7bbf0..c44c732 100644 --- a/templates/base.html +++ b/templates/base.html @@ -57,8 +57,9 @@ if ('serviceWorker' in navigator && 'PushManager' in window) { navigator.serviceWorker.register('{{ url_for("static", filename="service-worker.js") }}').then(function(registration) { console.log('ServiceWorker registration successful with scope: ', registration.scope); - // Check if we should ask for permission - if (document.referrer.includes('/login') || (performance.navigation.type == performance.navigation.TYPE_RELOAD && new URLSearchParams(window.location.search).has('loggedin'))) { + // Check for the 'loggedin' query parameter to trigger the prompt + const urlParams = new URLSearchParams(window.location.search); + if (urlParams.has('loggedin')) { askPermission(registration); } }, function(err) {