notherbase-fs 4.5.2 → 4.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notherbase-fs",
3
- "version": "4.5.2",
3
+ "version": "4.5.4",
4
4
  "description": "Functions to help make developing for NotherBase easier.",
5
5
  "exports": "./notherbase-fs.js",
6
6
  "scripts": {
@@ -10,11 +10,10 @@ export default class Creation {
10
10
  this.router = express.Router();
11
11
 
12
12
  this.router.get("/", this.explore);
13
- this.router.get("/the-front", this.explore);
14
- this.router.get(`/:region`, this.lock, this.explore);
15
- this.router.get(`/:region/:area`, this.lock, this.explore);
16
- this.router.get(`/:region/:area/:poi`, this.lock, this.explore);
17
- this.router.get(`/:region/:area/:poi/:detail`, this.lock, this.explore);
13
+ this.router.get("/:region", this.explore);
14
+ this.router.get("/:region/:area", this.explore);
15
+ this.router.get("/:region/:area/:poi", this.explore);
16
+ this.router.get("/:region/:area/:poi/:detail", this.explore);
18
17
 
19
18
  //void
20
19
  this.router.use(function(req, res) {
package/server/user.js CHANGED
@@ -102,7 +102,7 @@ export default class User {
102
102
  {
103
103
  let result = await this.validatePassword(req, req.body.password, spirit);
104
104
  if (result == "Authenticated.") {
105
- let other = await req.Spirit.recallOne("user", null, { email: req.body.email });
105
+ let other = await req.Spirit.findOne({ service: "user", email: req.body.email });
106
106
 
107
107
  if (check(res, !other, "Email already in use!")) {
108
108
  spirit.addBackup({
@@ -164,18 +164,24 @@ export default class User {
164
164
  const salt = await bcrypt.genSalt(10);
165
165
  const hash = await bcrypt.hash(req.body.password, salt);
166
166
 
167
- spirit = await req.Spirit.create("user", {
168
- username: req.body.username,
169
- password: hash,
170
- authLevels: [ "Basic" ],
171
- view: "compact",
172
- email: "",
173
- otp: {
174
- code: "",
175
- expires: 0
167
+ spirit = new req.Spirit({
168
+ service:"user",
169
+ _lastUpdate: Date.now(),
170
+ data: {
171
+ username: req.body.username,
172
+ password: hash,
173
+ authLevels: [ "Basic" ],
174
+ view: "compact",
175
+ email: "",
176
+ otp: {
177
+ code: "",
178
+ expires: 0
179
+ },
180
+ sessions: {}
176
181
  },
177
- sessions: {}
182
+ backups: []
178
183
  });
184
+ await spirit.save();
179
185
 
180
186
  success(res, "Registration successful!");
181
187
  }
@@ -265,7 +271,7 @@ export default class User {
265
271
  let user = await req.Spirit.findOne({ service: "user", username: req.session.username });
266
272
 
267
273
  if (check(res, user, "Account not found!")) {
268
- let data = await req.Spirit.recallAll(null, user._id);
274
+ let data = await req.Spirit.find({ parent: user._id });
269
275
  let dataToDownload = data.map(d => d);
270
276
 
271
277
  successJSON(res, "Data Downloaded", dataToDownload);
@@ -307,7 +313,14 @@ export default class User {
307
313
  let imported = 0;
308
314
  for (let i = 0; i < data.length; i++) {
309
315
  if (data[i].parent != null) {
310
- let spirit = await req.Spirit.create(data[i].service, data[i].data, user._id);
316
+ let spirit = new req.Spirit({
317
+ service: data[i].service,
318
+ _lastUpdate: data[i]._lastUpdate,
319
+ data: data[i].data,
320
+ parent: user._id,
321
+ backups: data[i].backups || []
322
+ });
323
+ await spirit.save();
311
324
  if (spirit) imported++;
312
325
  }
313
326
  }