notherbase-fs 4.5.3 → 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 +1 -1
- package/server/user.js +26 -13
package/package.json
CHANGED
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.
|
|
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 =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
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.
|
|
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 =
|
|
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
|
}
|