diff --git a/app/assets/javascripts/discourse/app/routes/application.js b/app/assets/javascripts/discourse/app/routes/application.js index 78fd3083612..aa26efc9f77 100644 --- a/app/assets/javascripts/discourse/app/routes/application.js +++ b/app/assets/javascripts/discourse/app/routes/application.js @@ -1,3 +1,4 @@ +import cookie from "discourse/lib/cookie"; import DiscourseURL, { userPath } from "discourse/lib/url"; import Category from "discourse/models/category"; import Composer from "discourse/models/composer"; @@ -230,7 +231,9 @@ const ApplicationRoute = DiscourseRoute.extend({ handleShowLogin() { if (this.siteSettings.enable_discourse_connect) { - const returnPath = encodeURIComponent(window.location.pathname); + const returnPath = cookie("destination_url") + ? getURL("/") + : encodeURIComponent(window.location.pathname); window.location = getURL("/session/sso?return_path=" + returnPath); } else { this.modal.show(LoginModal, {