@rpcbase/server 0.300.0 → 0.302.0
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,7 +1,7 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
const assert = require("assert")
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const UserStoredValues = require("../../models/UserStoredValues")
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
const set_stored_values = async(payload, ctx) => {
|
|
@@ -16,9 +16,9 @@ const set_stored_values = async(payload, ctx) => {
|
|
|
16
16
|
updates[key] = value
|
|
17
17
|
})
|
|
18
18
|
|
|
19
|
-
const res = await
|
|
19
|
+
const res = await UserStoredValues.updateOne(
|
|
20
20
|
{_owners: {$in: [user_id]}},
|
|
21
|
-
{$set: updates}
|
|
21
|
+
{$set: updates},
|
|
22
22
|
{ctx}
|
|
23
23
|
)
|
|
24
24
|
|
package/src/auth/sign_up.js
CHANGED
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
const {hash_password} = require("@rpcbase/std/crypto/hash")
|
|
3
3
|
|
|
4
4
|
const get_object_id = require("../../get_object_id")
|
|
5
|
-
|
|
6
5
|
const mongoose = require("../../mongoose")
|
|
7
6
|
|
|
7
|
+
const UserStoredValues = require("../models/UserStoredValues")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
8
11
|
const MIN_PASSWORD_LENGTH = 12
|
|
9
12
|
|
|
10
13
|
const sign_up = async(payload, ctx, session) => {
|
|
@@ -42,13 +45,17 @@ const sign_up = async(payload, ctx, session) => {
|
|
|
42
45
|
password_hash: hash
|
|
43
46
|
})
|
|
44
47
|
|
|
48
|
+
|
|
45
49
|
// sign the user in
|
|
46
50
|
const user_id = user._id.toString()
|
|
47
51
|
|
|
52
|
+
const values_store = new UserStoredValues({_owners: [user_id]})
|
|
53
|
+
|
|
48
54
|
// WARNING: it is now the responsibility of the app to add user.save with session
|
|
49
|
-
// await user.save({ctx})
|
|
55
|
+
// await user.save({ctx, session})
|
|
56
|
+
// await values_store.save({ctx, session})
|
|
50
57
|
|
|
51
|
-
return user
|
|
58
|
+
return {user, values_store}
|
|
52
59
|
}
|
|
53
60
|
|
|
54
61
|
module.exports = sign_up
|