@rpcbase/server 0.358.0 → 0.360.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/boot/shared.js +1 -1
- package/package.json +1 -3
- package/src/auth/get_account.js +1 -2
- package/src/auth/reset_password.js +2 -2
- package/src/auth/set_new_password.js +1 -1
- package/src/auth/sign_in.js +1 -2
- package/src/auth/sign_up.js +2 -5
- package/extend-expect/index.js +0 -7
- package/extend-expect/mactchers.js +0 -42
package/boot/shared.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.360.0",
|
|
4
4
|
"license": "SSPL-1.0",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -69,12 +69,10 @@
|
|
|
69
69
|
"cors": "2.8.5",
|
|
70
70
|
"debug": "4.3.6",
|
|
71
71
|
"dotenv": "16.4.5",
|
|
72
|
-
"expect": "29.7.0",
|
|
73
72
|
"express": "4.19.2",
|
|
74
73
|
"express-session": "1.18.0",
|
|
75
74
|
"firebase-admin": "12.3.0",
|
|
76
75
|
"glob": "11.0.0",
|
|
77
|
-
"jest-extended": "4.0.2",
|
|
78
76
|
"lodash": "4.17.21",
|
|
79
77
|
"mkdirp": "3.0.1",
|
|
80
78
|
"mongoose": "8.5.2",
|
package/src/auth/get_account.js
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
const assert = require("assert")
|
|
3
3
|
|
|
4
4
|
const mongoose = require("../../mongoose")
|
|
5
|
+
const User = require("../models/User")
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
const get_account = async(payload, ctx) => {
|
|
8
9
|
const {user_id} = payload
|
|
9
10
|
assert(user_id, "missing user_id")
|
|
10
11
|
|
|
11
|
-
const User = mongoose.model("User")
|
|
12
|
-
|
|
13
12
|
// verify we are only requesting our own account's info
|
|
14
13
|
const session_user_id = ctx.req.session.user_id
|
|
15
14
|
assert(user_id === session_user_id, "user ids don't match")
|
|
@@ -10,7 +10,9 @@ const get_random_str = require("@rpcbase/std/crypto/get_random_str")
|
|
|
10
10
|
|
|
11
11
|
const mailer = require("../../mailer")
|
|
12
12
|
const mongoose = require("../../mongoose")
|
|
13
|
+
|
|
13
14
|
const ResetPasswordToken = require("../models/ResetPasswordToken")
|
|
15
|
+
const User = require("../models/User")
|
|
14
16
|
|
|
15
17
|
const log = debug("rb:auth:reset_password")
|
|
16
18
|
|
|
@@ -20,8 +22,6 @@ const email_tpl = _template(require("./forgot_password_email.html"))
|
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
const reset_password = async({email}, ctx) => {
|
|
23
|
-
const User = mongoose.model("User")
|
|
24
|
-
|
|
25
25
|
if (!isEmail(email)) {
|
|
26
26
|
throw new Error("reset_password:: invalid email")
|
|
27
27
|
}
|
|
@@ -13,13 +13,13 @@ const mongoose = require("../../mongoose")
|
|
|
13
13
|
const set_new_password_email = require("./set_new_password_email.html")
|
|
14
14
|
|
|
15
15
|
const ResetPasswordToken = require("../models/ResetPasswordToken")
|
|
16
|
+
const User = require("../models/User")
|
|
16
17
|
|
|
17
18
|
const {APP_DOMAIN} = process.env
|
|
18
19
|
|
|
19
20
|
const email_tpl = _template(set_new_password_email)
|
|
20
21
|
|
|
21
22
|
const set_new_password = async({user_id, token, password}, ctx) => {
|
|
22
|
-
const User = mongoose.model("User")
|
|
23
23
|
|
|
24
24
|
const reset_tokens = await ResetPasswordToken.find({user_id})
|
|
25
25
|
.limit(100)
|
package/src/auth/sign_in.js
CHANGED
|
@@ -3,6 +3,7 @@ const {compare_hash} = require("@rpcbase/std/crypto/hash")
|
|
|
3
3
|
const debug = require("debug")
|
|
4
4
|
|
|
5
5
|
const mongoose = require("../../mongoose")
|
|
6
|
+
const User = require("../models/User")
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
const log = debug("rb:auth:signin")
|
|
@@ -17,8 +18,6 @@ const fail = () => ({
|
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
const sign_in = async({email, password}, ctx) => {
|
|
20
|
-
const User = mongoose.model("User")
|
|
21
|
-
|
|
22
21
|
const {req, res} = ctx
|
|
23
22
|
|
|
24
23
|
// find matching user
|
package/src/auth/sign_up.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
const {hash_password} = require("@rpcbase/std/crypto/hash")
|
|
3
3
|
|
|
4
|
-
const mongoose = require("../../mongoose")
|
|
5
|
-
|
|
6
4
|
const UserStoredValues = require("../models/UserStoredValues")
|
|
5
|
+
const User = require("../models/User")
|
|
6
|
+
const Invite = require("../models/Invite")
|
|
7
7
|
|
|
8
8
|
const MIN_PASSWORD_LENGTH = 12
|
|
9
9
|
|
|
@@ -12,9 +12,6 @@ const sign_up = async(payload, ctx, session) => {
|
|
|
12
12
|
expect(email).toBeEmail()
|
|
13
13
|
expect(password.length).toBeGreaterThanOrEqual(MIN_PASSWORD_LENGTH)
|
|
14
14
|
|
|
15
|
-
const User = mongoose.model("User")
|
|
16
|
-
const Invite = mongoose.model("Invite")
|
|
17
|
-
|
|
18
15
|
// check if the user already exists
|
|
19
16
|
const existing_user = await User.findOne({email}, null, {ctx, session})
|
|
20
17
|
|
package/extend-expect/index.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
const {expect} = require("expect")
|
|
3
|
-
|
|
4
|
-
const isMongoId = require("validator/lib/isMongoId")
|
|
5
|
-
const isEmail = require("validator/lib/isEmail")
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
expect.extend({
|
|
9
|
-
toBeMongoId: function(actual) {
|
|
10
|
-
const pass = isMongoId(actual)
|
|
11
|
-
|
|
12
|
-
if (pass) {
|
|
13
|
-
return {
|
|
14
|
-
message: () => `expected ${this.utils.printReceived(actual)} not to be a valid mongoId`,
|
|
15
|
-
pass: true,
|
|
16
|
-
}
|
|
17
|
-
} else {
|
|
18
|
-
return {
|
|
19
|
-
message: () => `expected ${this.utils.printReceived(actual)} to be a valid mongoId`,
|
|
20
|
-
pass: false,
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
toBeEmail: function(actual) {
|
|
25
|
-
const pass = actual && isEmail(actual)
|
|
26
|
-
|
|
27
|
-
if (pass) {
|
|
28
|
-
return {
|
|
29
|
-
message: () =>
|
|
30
|
-
`expected ${this.utils.printReceived(actual)} not to be a valid email address`,
|
|
31
|
-
pass: true,
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
return {
|
|
35
|
-
message: () => `expected ${this.utils.printReceived(actual)} to be a valid email address`,
|
|
36
|
-
pass: false,
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
global.expect = expect
|