diff --git a/assets/controllers/login_controller.js b/assets/controllers/login_controller.js index b73a1cf..a7f4568 100644 --- a/assets/controllers/login_controller.js +++ b/assets/controllers/login_controller.js @@ -2,10 +2,25 @@ import { Controller } from '@hotwired/stimulus'; import { getComponent } from '@symfony/ux-live-component'; export default class extends Controller { + static targets = ['nostrError']; + async initialize() { this.component = await getComponent(this.element); } - async loginAct() { + async loginAct(event) { + if (!window.nostr) { + if (this.hasNostrErrorTarget) { + this.nostrErrorTarget.textContent = 'Extension is not available.'; + this.nostrErrorTarget.style.display = 'block'; + } + event?.preventDefault(); + return; + } + if (this.hasNostrErrorTarget) { + this.nostrErrorTarget.textContent = ''; + this.nostrErrorTarget.style.display = 'none'; + } + const tags = [ ['u', window.location.origin + '/login'], ['method', 'POST'], @@ -35,4 +50,3 @@ export default class extends Controller { } } } - diff --git a/templates/components/UserMenu.html.twig b/templates/components/UserMenu.html.twig index 7131f91..25ac226 100644 --- a/templates/components/UserMenu.html.twig +++ b/templates/components/UserMenu.html.twig @@ -31,6 +31,7 @@