A platform for community discussion. Free, open, simple.
FEATURE: Add in-iframe sign-in flow for full app embed mode (#39756)
Rafael dos Santos Silva2808fdb04093
diff --git a/app/assets/stylesheets/common/base/embed-mode.scss b/app/assets/stylesheets/common/base/embed-mode.scssindex 6ea80495f78..8e4f08f8ebe 100644--- a/app/assets/stylesheets/common/base/embed-mode.scss+++ b/app/assets/stylesheets/common/base/embed-mode.scss@@ -249,3 +249,14 @@ body.embed-mode {}}}++.embed-auth-flow-modal {+ &__waiting {+ display: flex;+ flex-direction: column;+ align-items: center;+ gap: 1em;+ padding: 1em 0;+ text-align: center;+ }+}diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 8689a6f1602..293f2259d41 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -743,6 +743,16 @@ en:replying_to: "Replying to %{username}"editing_post: "Editing post"reply_placeholder: "Write a reply..."+ signin_flow:+ share_session_title: "Sign in to %{site_name}"+ share_session_message: "To continue, %{site_name} needs permission to use your existing session inside this page. Click below to allow access."+ signin_required_title: "Sign in to %{site_name}"+ signin_required_message: "We didn't find an existing %{site_name} session. Open a new tab to sign in or sign up, then return here to continue."+ open_signin_tab: "Open sign-in tab"+ waiting_title: "Waiting for sign-in"+ waiting_message: "Finish signing in in the new tab. This page will update automatically once you're done."+ cancel: "Cancel"+ sign_in_to_reply: "Sign in to reply"topic_count_all:one: "See %{count} new topic"diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 5948264e5ad..9f4ac0c03e3 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -2586,6 +2586,7 @@ en:allowed_embed_selectors: "A comma separated list of CSS elements that are allowed in embeds."allowed_href_schemes: "Schemes allowed in links in addition to http and https."embed_full_app: "Enable full app mode for embedded comments. When enabled, embedded comments will load the full Discourse application in an iframe, allowing users to interact with topics directly"+ embed_full_app_signin_flow: "When full app mode is enabled, intercept logged-out actions inside the iframe with a guided flow that opens a top-level sign-in tab that auto-closes on success. Only enable this when the embed is same-site to the host page (e.g. `forum.example.com` on `blog.example.com`) or when `same site cookies` is set to `None` — otherwise the iframe will not receive the session cookie after sign-in."suppress_third_party_analytics_in_embed: "Skip rendering third-party analytics scripts (Google Tag Manager, Google Analytics, Adobe Analytics) when Discourse is loaded inside a full app embed iframe. Prevents duplicate pageviews and tag firing when the host page already loads the same scripts."embed_post_limit: "Maximum number of posts to embed."embed_username_required: "The username for topic creation is required."diff --git a/config/site_settings.yml b/config/site_settings.ymlindex 360f8756fac..bc6e2b0c623 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -3374,6 +3374,10 @@ embedding:default: falseclient: truearea: "embedding"+ embed_full_app_signin_flow:+ default: true+ client: true+ area: "embedding"suppress_third_party_analytics_in_embed:default: truearea: "embedding"diff --git a/frontend/discourse/app/components/embed-mode-composer.gjs b/frontend/discourse/app/components/embed-mode-composer.gjsindex ab45b533da2..c502861f049 100644--- a/frontend/discourse/app/components/embed-mode-composer.gjs+++ b/frontend/discourse/app/components/embed-mode-composer.gjs@@ -14,6 +14,7 @@ import { i18n } from "discourse-i18n";export default class EmbedModeComposer extends Component {@service appEvents;@service currentUser;+ @service embedAuthFlow;@service site;@service store;@@ -77,6 +78,13 @@ export default class EmbedModeComposer extends Component {return this.currentUser && this.args.topic?.details?.can_create_post;}+ get showSigninCta() {+ if (!EmbedMode.enabled || this.currentUser) {+ return false;+ }+ return this.embedAuthFlow.isActive;+ }+get showFloatingTimelineButton() {return this.args.topic?.replyCount > 0 && !this.footerVisible;}@@ -142,6 +150,11 @@ export default class EmbedModeComposer extends Component {this.#composerApi?.setReply("");}+ @action+ handleSigninCtaClick() {+ this.embedAuthFlow.requestAccess({ intent: "login" });+ }+@actionasync handleSubmit({ raw }) {if (this.editingPost) {@@ -249,7 +262,15 @@ export default class EmbedModeComposer extends Component {}<template>- {{#if this.show}}+ {{#if this.showSigninCta}}+ <div class="embed-mode-composer embed-mode-composer--signin-cta">+ <DButton+ @action={{this.handleSigninCtaClick}}+ @label="embed_mode.signin_flow.sign_in_to_reply"+ class="btn-primary embed-mode-composer__signin-cta"+ />+ </div>+ {{else if this.show}}<div class="embed-mode-composer" {{this.setupEvents}}>{{#if this.showFloatingTimelineButton}}<div class="embed-floating-buttons">diff --git a/frontend/discourse/app/components/embed-topic-footer.gjs b/frontend/discourse/app/components/embed-topic-footer.gjsindex 45cbf115202..ac6c18ea562 100644--- a/frontend/discourse/app/components/embed-topic-footer.gjs+++ b/frontend/discourse/app/components/embed-topic-footer.gjs@@ -13,6 +13,7 @@ import { i18n } from "discourse-i18n";export default class EmbedTopicFooter extends Component {@service appEvents;@service currentUser;+ @service embedAuthFlow;@service siteSettings;@tracked footerButtonsVisible = false;@@ -74,7 +75,11 @@ export default class EmbedTopicFooter extends Component {@actionhandleReply() {if (!this.currentUser) {- window.open(getURL("/login"), "_blank");+ if (this.embedAuthFlow.isActive) {+ this.embedAuthFlow.requestAccess({ intent: "login" });+ } else {+ window.open(getURL("/login"), "_blank");+ }return;}diff --git a/frontend/discourse/app/components/modal/embed-auth-flow.gjs b/frontend/discourse/app/components/modal/embed-auth-flow.gjsnew file mode 100644index 00000000000..c3010c637ae--- /dev/null+++ b/frontend/discourse/app/components/modal/embed-auth-flow.gjs@@ -0,0 +1,99 @@+import Component from "@glimmer/component";+import { tracked } from "@glimmer/tracking";+import { on } from "@ember/modifier";+import DModal from "discourse/ui-kit/d-modal";+import dLoadingSpinner from "discourse/ui-kit/helpers/d-loading-spinner";+import { i18n } from "discourse-i18n";++export default class EmbedAuthFlowModal extends Component {+ @tracked waiting = false;++ // Native button click handler — runs synchronously in the same call stack+ // as the user gesture so requestStorageAccess() and window.open() inside+ // onConfirm see a valid user activation token.+ handleConfirm = () => {+ this.args.model.onConfirm();+ if (this.isSignin) {+ // Keep the modal up with a spinner so the user knows the iframe is+ // waiting for them to finish signing in in the popup.+ this.waiting = true;+ } else {+ this.args.closeModal();+ }+ };++ handleCancel = () => {+ if (this.waiting) {+ this.args.model.onCancel?.();+ }+ this.args.closeModal();+ };++ get isStorageAccess() {+ return this.args.model.kind === "storage-access";+ }++ get isSignin() {+ return this.args.model.kind === "signin";+ }++ get title() {+ if (this.waiting) {+ return i18n("embed_mode.signin_flow.waiting_title");+ }+ const key = this.isStorageAccess+ ? "embed_mode.signin_flow.share_session_title"+ : "embed_mode.signin_flow.signin_required_title";+ return i18n(key, { site_name: this.args.model.siteName });+ }++ get message() {+ const key = this.isStorageAccess+ ? "embed_mode.signin_flow.share_session_message"+ : "embed_mode.signin_flow.signin_required_message";+ return i18n(key, { site_name: this.args.model.siteName });+ }++ get confirmLabel() {+ return this.isStorageAccess+ ? i18n("embed_mode.allow_access")+ : i18n("embed_mode.signin_flow.open_signin_tab");+ }++ <template>+ <DModal+ @closeModal={{@closeModal}}+ @title={{this.title}}+ class="embed-auth-flow-modal"+ >+ <:body>+ {{#if this.waiting}}+ <div class="embed-auth-flow-modal__waiting">+ {{dLoadingSpinner size="large"}}+ <p>{{i18n "embed_mode.signin_flow.waiting_message"}}</p>+ </div>+ {{else}}+ <p>{{this.message}}</p>+ {{/if}}+ </:body>+ <:footer>+ {{#unless this.waiting}}+ <button+ type="button"+ class="btn btn-primary"+ {{on "click" this.handleConfirm}}+ >+ {{this.confirmLabel}}+ </button>+ {{/unless}}+ <button+ type="button"+ class="btn btn-default"+ {{on "click" this.handleCancel}}+ >+ {{i18n "embed_mode.signin_flow.cancel"}}+ </button>+ </:footer>+ </DModal>+ </template>+}diff --git a/frontend/discourse/app/instance-initializers/embed-signin-popup-callback.js b/frontend/discourse/app/instance-initializers/embed-signin-popup-callback.jsnew file mode 100644index 00000000000..8dfbd672aef--- /dev/null+++ b/frontend/discourse/app/instance-initializers/embed-signin-popup-callback.js@@ -0,0 +1,47 @@+const SESSION_KEY_PENDING = "discourse:embed:popup-callback";++export default {+ after: "inject-objects",++ initialize(owner) {+ // The query param is the only reliable signal — Discourse's default COOP+ // (`same-origin-allow-popups`) mismatches a typical embedding host's+ // (`unsafe-none`), which severs `window.opener` on the first popup load.+ if (paramPresent()) {+ try {+ sessionStorage.setItem(SESSION_KEY_PENDING, "1");+ } catch {}+ }++ let pending = false;+ try {+ pending = sessionStorage.getItem(SESSION_KEY_PENDING) === "1";+ } catch {}++ if (!pending) {+ return;+ }++ const currentUser = owner.lookup("service:current-user");+ if (!currentUser) {+ return;+ }++ try {+ sessionStorage.removeItem(SESSION_KEY_PENDING);+ } catch {}++ // The iframe detects sign-in via session polling, so this self-close is+ // just UX — silently no-ops if window.close() is disallowed.+ window.close();+ },+};++function paramPresent() {+ try {+ const params = new URLSearchParams(window.location.search);+ return params.get("embed_signin_callback") === "1";+ } catch {+ return false;+ }+}diff --git a/frontend/discourse/app/instance-initializers/embed-storage-access.js b/frontend/discourse/app/instance-initializers/embed-storage-access.jsindex 8c15afe117e..6d708f54518 100644--- a/frontend/discourse/app/instance-initializers/embed-storage-access.js+++ b/frontend/discourse/app/instance-initializers/embed-storage-access.js@@ -9,6 +9,15 @@ export default {return;}+ // The embed-auth-flow service handles storage access (and sign-in) when+ // embed_full_app_signin_flow is enabled. Eagerly look it up so its+ // post-reload state machine runs, then skip the legacy on-load prompt.+ const siteSettings = owner.lookup("service:site-settings");+ if (siteSettings.embed_full_app_signin_flow) {+ owner.lookup("service:embed-auth-flow");+ return;+ }+const capabilities = owner.lookup("service:capabilities");// Storage Access API is needed for Safari's ITP (Intelligent Tracking Prevention)diff --git a/frontend/discourse/app/routes/application.js b/frontend/discourse/app/routes/application.jsindex 2818dd58303..888632fc9a8 100644--- a/frontend/discourse/app/routes/application.js+++ b/frontend/discourse/app/routes/application.js@@ -22,6 +22,7 @@ export default class ApplicationRoute extends DiscourseRoute {@service currentUser;@service dialog;@service documentTitle;+ @service embedAuthFlow;@service historyStore;@service loadingSlider;@service modal;@@ -179,7 +180,11 @@ export default class ApplicationRoute extends DiscourseRoute {@actionshowLogin(props = {}) {if (EmbedMode.enabled) {- window.open(getURL("/login"), "_blank");+ if (this.embedAuthFlow.isActive) {+ this.embedAuthFlow.requestAccess({ intent: "login" });+ } else {+ window.open(getURL("/login"), "_blank");+ }return;}@@ -195,7 +200,11 @@ export default class ApplicationRoute extends DiscourseRoute {@actionshowCreateAccount(props = {}) {if (EmbedMode.enabled) {- window.open(getURL("/signup"), "_blank");+ if (this.embedAuthFlow.isActive) {+ this.embedAuthFlow.requestAccess({ intent: "signup" });+ } else {+ window.open(getURL("/signup"), "_blank");+ }return;}diff --git a/frontend/discourse/app/services/embed-auth-flow.js b/frontend/discourse/app/services/embed-auth-flow.jsnew file mode 100644index 00000000000..7cb2f8cb471--- /dev/null+++ b/frontend/discourse/app/services/embed-auth-flow.js@@ -0,0 +1,224 @@+import Service, { service } from "@ember/service";+import EmbedAuthFlowModal from "discourse/components/modal/embed-auth-flow";+import { ajax } from "discourse/lib/ajax";+import EmbedMode from "discourse/lib/embed-mode";+import getURL from "discourse/lib/get-url";++const SESSION_POLL_INTERVAL_MS = 3000;+const SESSION_POLL_MAX_MS = 5 * 60 * 1000;++export default class EmbedAuthFlow extends Service {+ @service modal;+ @service siteSettings;++ _popup = null;+ _pollTimer = null;+ _pollStartedAt = null;+ _pollInFlight = false;++ willDestroy() {+ super.willDestroy(...arguments);+ this._stopPolling();+ }++ get isActive() {+ // The flow assumes the iframe can receive its cookies after popup+ // sign-in — true when the embed is same-site to the host page (any+ // SameSite setting) or when SameSite=None is configured for cross-site+ // embeds. Validating that at runtime would need the Public Suffix List;+ // we trust the admin to enable this only on a compatible deployment.+ return EmbedMode.enabled && this.siteSettings.embed_full_app_signin_flow;+ }++ get _supportsStorageAccess() {+ return (+ typeof document.hasStorageAccess === "function" &&+ typeof document.requestStorageAccess === "function"+ );+ }++ get _siteName() {+ return this.siteSettings.title;+ }++ async requestAccess({ intent = "login" } = {}) {+ if (!this.isActive) {+ return false;+ }++ // hasStorageAccess() is the browser-agnostic signal for cookie+ // partitioning — returns true on same-site embeds (and same-origin+ // iframes) where nothing's blocked, false when the iframe's cookie jar+ // is partitioned (Safari ITP, Firefox Total Cookie Protection, Chrome+ // 3p cookie phaseout). When partitioned we bridge via Storage Access+ // so the iframe's post-signin polling can see the popup's cookies.+ if (!this._supportsStorageAccess) {+ // Old browser with no API to bridge — fall back to a top-level login+ // tab so the user isn't dead-ended inside the iframe.+ this._openLegacyLoginTab(intent);+ return true;+ }++ let hasAccess = false;+ try {+ hasAccess = await document.hasStorageAccess();+ } catch {+ hasAccess = false;+ }++ if (!hasAccess) {+ this._promptForStorageAccess(intent);+ return true;+ }++ // We have access — if the user is already signed in to Discourse in+ // another tab, the iframe was just missing the cookie due to+ // partitioning. Reloading is enough; no popup needed.+ if (await this._isUserSignedIn()) {+ this._reload();+ return true;+ }++ this._promptForSignin(intent);+ return true;+ }++ _promptForStorageAccess(intent) {+ this.modal.show(EmbedAuthFlowModal, {+ model: {+ kind: "storage-access",+ siteName: this._siteName,+ // Runs synchronously inside the button's click handler so user+ // activation is valid for requestStorageAccess().+ onConfirm: () => {+ document+ .requestStorageAccess()+ .then(() => {+ // Re-run requestAccess so the unified post-access path runs+ // — including the already-signed-in check, which otherwise+ // sends the user through an unnecessary popup that just+ // bounces back to the homepage.+ this.requestAccess({ intent });+ })+ .catch(() => {+ // Storage access was denied; the iframe cannot access the+ // session even after a sign-in popup, so chaining one would+ // dead-end. The user can retry their original action to be+ // re-prompted.+ });+ },+ },+ });+ }++ async _isUserSignedIn() {+ try {+ await ajax("/session/current.json");+ return true;+ } catch {+ return false;+ }+ }++ _reload() {+ window.location.reload();+ }++ _promptForSignin(intent) {+ this.modal.show(EmbedAuthFlowModal, {+ model: {+ kind: "signin",+ siteName: this._siteName,+ // Runs synchronously inside the button's click handler so the popup+ // is not blocked.+ onConfirm: () => {+ this._openSigninPopup(intent);+ },+ onCancel: () => {+ this._stopPolling();+ },+ },+ });+ }++ _openLegacyLoginTab(intent) {+ const path = intent === "signup" ? "/signup" : "/login";+ window.open(getURL(path), "_blank");+ }++ _openSigninPopup(intent) {+ const path = intent === "signup" ? "/signup" : "/login";+ const url = new URL(getURL(path), window.location.origin);+ url.searchParams.set("embed_signin_callback", "1");++ const popup = window.open(url.toString(), "_blank");+ if (!popup) {+ return;+ }++ this._popup = popup;+ this._startPolling();+ }++ _startPolling() {+ // Polled rather than postMessage-driven because OAuth providers (e.g.+ // Discourse ID) typically set Cross-Origin-Opener-Policy, which severs+ // window.opener once the popup navigates off-origin — so the popup+ // can't reliably signal success back. The iframe just watches the+ // session endpoint directly.+ this._pollStartedAt = Date.now();+ this._pollTimer = setInterval(+ () => this._pollOnce(),+ SESSION_POLL_INTERVAL_MS+ );+ }++ async _pollOnce() {+ if (this._pollInFlight) {+ return;+ }++ const elapsed = Date.now() - this._pollStartedAt;+ if (elapsed > SESSION_POLL_MAX_MS) {+ this._giveUpWaiting();+ return;+ }++ this._pollInFlight = true;+ try {+ await ajax("/session/current.json");+ this._handleSigninSuccess();+ } catch {+ // 404 (not signed in) or transient — keep polling.+ } finally {+ this._pollInFlight = false;+ }+ }++ _stopPolling() {+ if (this._pollTimer) {+ clearInterval(this._pollTimer);+ this._pollTimer = null;+ }+ if (this._popup && !this._popup.closed) {+ this._popup.close();+ }+ this._popup = null;+ this._pollStartedAt = null;+ }++ _giveUpWaiting() {+ // Polling expired without a sign-in — dismiss the waiting modal so the+ // user isn't left staring at a spinner that's no longer doing anything.+ this._stopPolling();+ this.modal.close();+ }++ _handleSigninSuccess() {+ this._stopPolling();+ // Storage access (when needed) was granted before the popup opened and+ // persists across iframe reload, so reloading is enough to pick up the+ // session cookie that the popup just established first-party.+ this._reload();+ }+}diff --git a/frontend/discourse/tests/unit/services/embed-auth-flow-test.js b/frontend/discourse/tests/unit/services/embed-auth-flow-test.jsnew file mode 100644index 00000000000..6ed85e83241--- /dev/null+++ b/frontend/discourse/tests/unit/services/embed-auth-flow-test.js@@ -0,0 +1,200 @@+import { setupTest } from "ember-qunit";+import { module, test } from "qunit";+import sinon from "sinon";+import EmbedAuthFlowModal from "discourse/components/modal/embed-auth-flow";+import EmbedMode from "discourse/lib/embed-mode";++function buildService(owner) {+ owner.unregister("service:embed-auth-flow");+ return owner.lookup("service:embed-auth-flow");+}++function modalKind(stub, callIndex = 0) {+ return stub.getCall(callIndex).args[1]?.model?.kind;+}++function modalOnConfirm(stub, callIndex = 0) {+ return stub.getCall(callIndex).args[1]?.model?.onConfirm;+}++module("Unit | Service | embed-auth-flow", function (hooks) {+ setupTest(hooks);++ hooks.beforeEach(function () {+ this.siteSettings = this.owner.lookup("service:site-settings");+ this.modalService = this.owner.lookup("service:modal");++ this.originalEmbedMode = EmbedMode.enabled;+ EmbedMode.enabled = true;+ this.siteSettings.embed_full_app_signin_flow = true;++ this.modalShow = sinon.stub(this.modalService, "show");+ this.windowOpen = sinon+ .stub(window, "open")+ .returns({ closed: false, close: sinon.stub() });+ });++ hooks.afterEach(function () {+ EmbedMode.enabled = this.originalEmbedMode;+ sinon.restore();+ });++ test("isActive requires embed mode and the site setting", function (assert) {+ let service = buildService(this.owner);+ assert.true(service.isActive, "active when both are on");++ EmbedMode.enabled = false;+ service = buildService(this.owner);+ assert.false(service.isActive, "inactive when embed mode is off");++ EmbedMode.enabled = true;+ this.siteSettings.embed_full_app_signin_flow = false;+ service = buildService(this.owner);+ assert.false(service.isActive, "inactive when site setting is off");+ });++ test("requestAccess is a no-op when inactive", async function (assert) {+ EmbedMode.enabled = false;+ const service = buildService(this.owner);++ const result = await service.requestAccess();++ assert.false(result, "returns false");+ assert.true(this.modalShow.notCalled, "no modal shown");+ });++ test("storage access already granted goes straight to sign-in", async function (assert) {+ sinon.stub(document, "hasStorageAccess").resolves(true);++ const service = buildService(this.owner);+ sinon.stub(service, "_isUserSignedIn").resolves(false);++ await service.requestAccess({ intent: "login" });++ assert.strictEqual(+ this.modalShow.firstCall.args[0],+ EmbedAuthFlowModal,+ "uses our custom modal component (native buttons preserve user activation)"+ );+ assert.strictEqual(+ modalKind(this.modalShow),+ "signin",+ "skips the storage-access prompt"+ );+ });++ test("partitioned cookies prompt for Storage Access first", async function (assert) {+ sinon.stub(document, "hasStorageAccess").resolves(false);++ const service = buildService(this.owner);+ await service.requestAccess({ intent: "login" });++ assert.strictEqual(+ modalKind(this.modalShow),+ "storage-access",+ "partitioned cookie jar needs to be bridged before sign-in"+ );+ });++ test("no Storage Access API falls back to legacy login tab", async function (assert) {+ const service = buildService(this.owner);+ sinon.stub(service, "_supportsStorageAccess").get(() => false);++ await service.requestAccess({ intent: "login" });++ assert.true(this.modalShow.notCalled, "no modal shown");+ assert.true(this.windowOpen.calledOnce, "legacy login tab opened");+ const url = this.windowOpen.firstCall.args[0];+ assert.true(url.includes("/login"), "uses /login path");+ assert.false(+ url.includes("embed_signin_callback"),+ "no callback param — would be useless without storage access"+ );+ });++ test("storage access denial does not chain to a sign-in popup", async function (assert) {+ sinon.stub(document, "hasStorageAccess").resolves(false);+ sinon.stub(document, "requestStorageAccess").rejects(new Error("denied"));++ const service = buildService(this.owner);+ await service.requestAccess({ intent: "login" });++ modalOnConfirm(this.modalShow)();++ await new Promise((resolve) => setTimeout(resolve, 0));++ assert.strictEqual(+ this.modalShow.callCount,+ 1,+ "no second modal after denial — user retries on next click"+ );+ });++ test("storage access grant chains into the sign-in modal", async function (assert) {+ const hasStorageAccess = sinon.stub(document, "hasStorageAccess");+ hasStorageAccess.onFirstCall().resolves(false);+ hasStorageAccess.resolves(true);+ sinon.stub(document, "requestStorageAccess").resolves();++ const service = buildService(this.owner);+ sinon.stub(service, "_isUserSignedIn").resolves(false);++ await service.requestAccess({ intent: "signup" });++ assert.strictEqual(+ modalKind(this.modalShow),+ "storage-access",+ "starts with the storage-access prompt"+ );++ modalOnConfirm(this.modalShow)();++ await new Promise((resolve) => setTimeout(resolve, 0));++ assert.strictEqual(+ this.modalShow.callCount,+ 2,+ "shows the sign-in modal once access is granted"+ );+ assert.strictEqual(+ modalKind(this.modalShow, 1),+ "signin",+ "chains directly into sign-in without reloading"+ );+ });++ test("already-signed-in user gets a reload instead of the sign-in popup", async function (assert) {+ sinon.stub(document, "hasStorageAccess").resolves(true);++ const service = buildService(this.owner);+ sinon.stub(service, "_isUserSignedIn").resolves(true);+ const reload = sinon.stub(service, "_reload");++ await service.requestAccess({ intent: "login" });++ assert.true(reload.calledOnce, "reload invoked to pick up the session");+ assert.true(+ this.modalShow.notCalled,+ "sign-in modal is skipped — no popup needed"+ );+ });++ test("opening sign-in popup uses /signup for signup intent", async function (assert) {+ sinon.stub(document, "hasStorageAccess").resolves(true);++ const service = buildService(this.owner);+ sinon.stub(service, "_isUserSignedIn").resolves(false);++ await service.requestAccess({ intent: "signup" });++ modalOnConfirm(this.modalShow)();++ assert.true(this.windowOpen.calledOnce, "window.open invoked");+ const url = this.windowOpen.firstCall.args[0];+ assert.true(url.includes("/signup"), "uses signup path");+ assert.true(+ url.includes("embed_signin_callback=1"),+ "appends callback flag"+ );+ });+});