diff --git a/app/assets/javascripts/discourse/app/controllers/create-account.js b/app/assets/javascripts/discourse/app/controllers/create-account.js index 5b9de9130e9..198dbe92a8c 100644 --- a/app/assets/javascripts/discourse/app/controllers/create-account.js +++ b/app/assets/javascripts/discourse/app/controllers/create-account.js @@ -359,7 +359,7 @@ export default Controller.extend( actions: { externalLogin(provider) { - this.login.send("externalLogin", provider); + this.login.send("externalLogin", provider, { signup: true }); }, createAccount() { diff --git a/app/assets/javascripts/discourse/app/controllers/invites-show.js b/app/assets/javascripts/discourse/app/controllers/invites-show.js index 523aa47ca51..875820daf77 100644 --- a/app/assets/javascripts/discourse/app/controllers/invites-show.js +++ b/app/assets/javascripts/discourse/app/controllers/invites-show.js @@ -233,6 +233,7 @@ export default Controller.extend( externalLogin(provider) { provider.doLogin({ + signup: true, params: { origin: window.location.href, }, diff --git a/app/assets/javascripts/discourse/app/controllers/login.js b/app/assets/javascripts/discourse/app/controllers/login.js index 530460f3902..fe6b32b757a 100644 --- a/app/assets/javascripts/discourse/app/controllers/login.js +++ b/app/assets/javascripts/discourse/app/controllers/login.js @@ -267,13 +267,15 @@ export default Controller.extend(ModalFunctionality, { return false; }, - externalLogin(loginMethod) { + externalLogin(loginMethod, { signup = false } = {}) { if (this.loginDisabled) { return; } this.set("loggingIn", true); - loginMethod.doLogin().catch(() => this.set("loggingIn", false)); + loginMethod + .doLogin({ signup: signup }) + .catch(() => this.set("loggingIn", false)); }, createAccount() { diff --git a/app/assets/javascripts/discourse/app/models/login-method.js b/app/assets/javascripts/discourse/app/models/login-method.js index db0882f890a..399e7a65fec 100644 --- a/app/assets/javascripts/discourse/app/models/login-method.js +++ b/app/assets/javascripts/discourse/app/models/login-method.js @@ -23,7 +23,7 @@ const LoginMethod = EmberObject.extend({ return this.message_override || I18n.t(`login.${this.name}.message`); }, - doLogin({ reconnect = false, params = {} } = {}) { + doLogin({ reconnect = false, signup = false, params = {} } = {}) { if (this.customLogin) { this.customLogin(); return Promise.resolve(); @@ -40,6 +40,10 @@ const LoginMethod = EmberObject.extend({ params["reconnect"] = true; } + if (signup) { + params["signup"] = true; + } + const paramKeys = Object.keys(params); if (paramKeys.length > 0) { authUrl += "?"; diff --git a/app/assets/javascripts/discourse/app/routes/application.js b/app/assets/javascripts/discourse/app/routes/application.js index 414860ecbd5..243cf81913e 100644 --- a/app/assets/javascripts/discourse/app/routes/application.js +++ b/app/assets/javascripts/discourse/app/routes/application.js @@ -258,15 +258,17 @@ const ApplicationRoute = DiscourseRoute.extend(OpenComposer, { const returnPath = encodeURIComponent(window.location.pathname); window.location = getURL("/session/sso?return_path=" + returnPath); } else { - this._autoLogin("createAccount", "create-account"); + this._autoLogin("createAccount", "create-account", { signup: true }); } }, - _autoLogin(modal, modalClass, notAuto) { + _autoLogin(modal, modalClass, notAuto, { signup = false } = {}) { const methods = findAll(); if (!this.siteSettings.enable_local_logins && methods.length === 1) { - this.controllerFor("login").send("externalLogin", methods[0]); + this.controllerFor("login").send("externalLogin", methods[0], { + signup: signup, + }); } else { showModal(modal); this.controllerFor("modal").set("modalClass", modalClass);