FIX: Return a deprecation for `Discourse.Session`

FIX: Return a deprecation for Discourse.Session

diff --git a/app/assets/javascripts/discourse/models/session.js.es6 b/app/assets/javascripts/discourse/models/session.js.es6
index f323540640..9f05080ea9 100644
--- a/app/assets/javascripts/discourse/models/session.js.es6
+++ b/app/assets/javascripts/discourse/models/session.js.es6
@@ -1,5 +1,6 @@
 import RestModel from "discourse/models/rest";
 import Singleton from "discourse/mixins/singleton";
+import deprecated from "discourse-common/lib/deprecated";
 
 // A data model representing current session data. You can put transient
 // data here you might want later. It is not stored or serialized anywhere.
@@ -10,4 +11,14 @@ const Session = RestModel.extend({
 });
 
 Session.reopenClass(Singleton);
+
+Object.defineProperty(Discourse, "Session", {
+  get() {
+    deprecated("Import the Session object instead of using Discourse.Session", {
+      since: "2.4.0",
+      dropFrom: "2.5.0"
+    });
+    return Session;
+  }
+});
 export default Session;

GitHub sha: c0e105fc

1 Like