notherbase-fs 1.1.37 → 1.1.40

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.
@@ -33,9 +33,23 @@ let front = function front(detail) {
33
33
  detail.options.main = `${dir}/views/${detail.options.main}`;
34
34
 
35
35
  router.get(`/${detail.name}`, async function(req, res) {
36
+ let context = {
37
+ siteTitle: "NotherBase | The Front",
38
+ user: null,
39
+ styles: detail.options.styles,
40
+ externalStyles: detail.options.externalStyles,
41
+ main: detail.options.main,
42
+ localScripts: detail.options.localScripts,
43
+ inventory: null,
44
+ query: req.query
45
+ }
46
+
36
47
  if (connectionSuccess) {
48
+ context.user = req.session.currentUserFull;
49
+
37
50
  try {
38
51
  const foundInventory = await inventory.findOne({ user: req.session.currentUser }).populate("items.item");
52
+ context.inventory = foundInventory;
39
53
 
40
54
  if (detail.options.needsKey !== "" && foundInventory) {
41
55
  let hasKey = false;
@@ -45,29 +59,9 @@ let front = function front(detail) {
45
59
  }
46
60
 
47
61
  if (!hasKey) res.redirect(detail.options.dropOff);
48
- else res.render(`explorer`,
49
- {
50
- siteTitle: "NotherBase | The Front",
51
- user: req.session.currentUserFull,
52
- styles: detail.options.styles,
53
- externalStyles: detail.options.externalStyles,
54
- main: detail.options.main,
55
- localScripts: detail.options.localScripts,
56
- inventory: foundInventory,
57
- query: req.query
58
- });
62
+ else res.render(`explorer`, context);
59
63
  }
60
- else res.render(`explorer`,
61
- {
62
- siteTitle: "NotherBase | The Front",
63
- user: req.session.currentUserFull,
64
- styles: detail.options.styles,
65
- externalStyles: detail.options.externalStyles,
66
- main: detail.options.main,
67
- localScripts: detail.options.localScripts,
68
- inventory: foundInventory,
69
- query: req.query
70
- });
64
+ else res.render(`explorer`, context);
71
65
  }
72
66
  catch(err) {
73
67
  console.log(err);
@@ -76,17 +70,7 @@ let front = function front(detail) {
76
70
  else {
77
71
  console.log("no db connection");
78
72
 
79
- res.render(`explorer`,
80
- {
81
- siteTitle: "NotherBase | The Front",
82
- user: null,
83
- styles: detail.options.styles,
84
- externalStyles: detail.options.externalStyles,
85
- main: detail.options.main,
86
- localScripts: detail.options.localScripts,
87
- inventory: null,
88
- query: req.query
89
- });
73
+ res.render(`explorer`, context);
90
74
  }
91
75
  });
92
76
  }
@@ -48,8 +48,8 @@ router.post("/login", async function(req, res) {
48
48
 
49
49
  if (foundAccount) {
50
50
  if (await bcrypt.compare(req.body.password, foundAccount.password)) {
51
- req.session.currentuser = foundAccount._id;
52
- req.session.currentuserFull = foundAccount;
51
+ req.session.currentUser = foundAccount._id;
52
+ req.session.currentUserFull = foundAccount;
53
53
 
54
54
  res.status(200).send("Login successful!");
55
55
  }
@@ -81,9 +81,9 @@ router.get("/logout", authCheck, async function(req, res) {
81
81
 
82
82
  router.get("/all", authCheck, async function(req, res) {
83
83
  try {
84
- let foundusers = await user.find({}, 'username coin home authLevels location');
84
+ let foundUsers = await user.find({}, 'username coin home authLevels location');
85
85
 
86
- res.status(200).send({ foundusers: foundusers });
86
+ res.status(200).send({ foundUsers: foundUsers });
87
87
  }
88
88
  catch(err) {
89
89
  res.status(500).end();
@@ -93,7 +93,7 @@ router.get("/all", authCheck, async function(req, res) {
93
93
 
94
94
  router.delete("/", authCheck, async function(req, res) {
95
95
  try {
96
- const found = await user.findByIdAndDelete(req.session.currentuser);
96
+ const found = await user.findByIdAndDelete(req.session.currentUser);
97
97
 
98
98
  if (!found) console.log("Could not find account. No deletion!");
99
99
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notherbase-fs",
3
- "version": "1.1.37",
3
+ "version": "1.1.40",
4
4
  "description": "Functions to help make developing for NotherBase easier.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server.js CHANGED
@@ -44,7 +44,10 @@ module.exports = function start(frontRouter, exploreRouter, dbConnected) {
44
44
  resave: false,
45
45
  saveUninitialized: false
46
46
  }));
47
+
48
+ console.log("sessions enabled");
47
49
  }
50
+ else console.log("sessions disabled");
48
51
 
49
52
  io.on('connection', (socket) => {
50
53
  socket.join(socket.handshake.query.room);