notherbase-fs 4.0.14 → 4.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/controllers/creation.js +1 -3
- package/controllers/user.js +1 -1
- package/notherbase-fs.js +13 -14
- package/package.json +1 -1
package/controllers/creation.js
CHANGED
|
@@ -69,9 +69,7 @@ export default class Creation {
|
|
|
69
69
|
|
|
70
70
|
if (req.session.currentUser) {
|
|
71
71
|
context.user = await req.db.Spirit.recallOne("user", null, { username: req.session.currentUser });
|
|
72
|
-
}
|
|
73
|
-
console.log(req.session.currentUser, context.user);
|
|
74
|
-
|
|
72
|
+
}
|
|
75
73
|
|
|
76
74
|
res.render(req.toRender, context);
|
|
77
75
|
}
|
package/controllers/user.js
CHANGED
|
@@ -106,7 +106,7 @@ export default class User {
|
|
|
106
106
|
if (check(res, passResult, "Password doesn't match the username.")) {
|
|
107
107
|
req.session.currentUser = req.body.username;
|
|
108
108
|
|
|
109
|
-
success(res, "Logged in.",
|
|
109
|
+
success(res, "Logged in.", req.body.username);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
}
|
package/notherbase-fs.js
CHANGED
|
@@ -19,6 +19,16 @@ import MongoStore from 'connect-mongo';
|
|
|
19
19
|
class NotherBaseFS {
|
|
20
20
|
constructor(globals = {}, bases = {}) {
|
|
21
21
|
this.bases = bases;
|
|
22
|
+
|
|
23
|
+
this.app = express();
|
|
24
|
+
this.server = http.createServer(this.app);
|
|
25
|
+
this.io = new Server(this.server);
|
|
26
|
+
this.spiritWorld = new SpiritWorld(this.io);
|
|
27
|
+
this.creation = new Creation(bases);
|
|
28
|
+
|
|
29
|
+
//be safe, needs to be before session
|
|
30
|
+
if (process.env.PRODUCTION == "true") this.app.set('trust proxy', 1);
|
|
31
|
+
|
|
22
32
|
let baseKeys = Object.keys(this.bases);
|
|
23
33
|
let mongoStore = MongoStore.create({ mongoUrl: process.env.MONGODB_URI });
|
|
24
34
|
for (let i = 0; i < baseKeys.length; i++) {
|
|
@@ -36,12 +46,6 @@ class NotherBaseFS {
|
|
|
36
46
|
}
|
|
37
47
|
});
|
|
38
48
|
}
|
|
39
|
-
|
|
40
|
-
this.app = express();
|
|
41
|
-
this.server = http.createServer(this.app);
|
|
42
|
-
this.io = new Server(this.server);
|
|
43
|
-
this.spiritWorld = new SpiritWorld(this.io);
|
|
44
|
-
this.creation = new Creation(bases);
|
|
45
49
|
|
|
46
50
|
//set views path
|
|
47
51
|
this.app.set("view engine", "ejs");
|
|
@@ -61,10 +65,7 @@ class NotherBaseFS {
|
|
|
61
65
|
if (split[split.length - 2].length < 3) req.hosting = split[split.length - 3] + split[split.length - 2];
|
|
62
66
|
else req.hosting = split[split.length - 2];
|
|
63
67
|
}
|
|
64
|
-
else req.hosting = split[0];
|
|
65
|
-
console.log(req.hosting);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
else req.hosting = split[0];
|
|
68
69
|
|
|
69
70
|
req.contentPath = this.bases[req.hosting].directory;
|
|
70
71
|
next();
|
|
@@ -74,6 +75,8 @@ class NotherBaseFS {
|
|
|
74
75
|
this.bases[req.hosting].favicon(req, res, next);
|
|
75
76
|
});
|
|
76
77
|
|
|
78
|
+
|
|
79
|
+
|
|
77
80
|
//enable cookies
|
|
78
81
|
this.app.use((req, res, next) => {
|
|
79
82
|
this.bases[req.hosting].session(req, res, next);
|
|
@@ -84,13 +87,9 @@ class NotherBaseFS {
|
|
|
84
87
|
this.app.use((req, res, next) => {
|
|
85
88
|
this.bases[req.hosting].static(req, res, next);
|
|
86
89
|
});
|
|
87
|
-
|
|
88
|
-
//be safe
|
|
89
|
-
if (process.env.PRODUCTION == "true") this.app.set('trust proxy', 1);
|
|
90
90
|
|
|
91
91
|
//provide database access and etc to use in routes
|
|
92
92
|
this.app.use((req, res, next) => {
|
|
93
|
-
console.log(req.session);
|
|
94
93
|
req.globals = globals;
|
|
95
94
|
req.db = Models;
|
|
96
95
|
req.lock = false;
|