@rpcbase/server 0.90.0 → 0.93.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/cli/run_native.js CHANGED
@@ -53,6 +53,11 @@ const init_processes = (args) => {
53
53
  // yarn dev
54
54
  cmd: ["yarn", ["dev"]]
55
55
  },
56
+ {
57
+ name: "queue",
58
+ dirs: [],
59
+ cmd: ["yarn", ["dev-queue"]]
60
+ },
56
61
  // mongodb database
57
62
  {
58
63
  name: "database",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/server",
3
- "version": "0.90.0",
3
+ "version": "0.93.0",
4
4
  "license": "SSPL-1.0",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -10,7 +10,7 @@
10
10
  "test": "echo \"Error: no test specified\" && exit 0"
11
11
  },
12
12
  "dependencies": {
13
- "@rpcbase/agent": "0.10.0",
13
+ "@rpcbase/agent": "0.11.0",
14
14
  "@rpcbase/std": "0.3.0",
15
15
  "body-parser": "1.20.0",
16
16
  "bull": "4.8.5",
@@ -22,10 +22,11 @@
22
22
  "express-session": "1.17.3",
23
23
  "glob": "8.0.3",
24
24
  "lodash": "4.17.21",
25
+ "mkdirp": "1.0.4",
25
26
  "mongoose": "6.5.3",
26
27
  "picocolors": "1.0.0",
27
- "postmark": "3.0.12",
28
- "redis": "4.2.0",
28
+ "postmark": "3.0.13",
29
+ "redis": "4.3.0",
29
30
  "request-ip": "3.3.0",
30
31
  "validator": "13.7.0",
31
32
  "yargs": "17.5.1"
@@ -1,10 +1,19 @@
1
1
  /* @flow */
2
+ const debug = require("debug")
3
+
4
+
5
+ const log = debug("rb:auth:check_session")
6
+
2
7
 
3
8
  const check_session = async(payload, ctx) => {
4
9
  const {req} = ctx
5
- // console.log("session check", req.session)
10
+
11
+ log("session:", req.session)
6
12
 
7
13
  const is_signed_in = !!req.session.user_id
14
+
15
+ log("is_signed_in:", is_signed_in)
16
+
8
17
  return {
9
18
  status: "ok",
10
19
  is_signed_in,
@@ -1,8 +1,12 @@
1
1
  /* @flow */
2
2
  const {compare_hash} = require("@rpcbase/std/crypto/hash")
3
+ const debug = require("debug")
3
4
 
4
5
  const mongoose = require("../../mongoose")
5
6
 
7
+
8
+ const log = debug("rb:auth:signin")
9
+
6
10
  const fail = () => ({
7
11
  errors: {form: "Invalid email or password"}
8
12
  })
@@ -13,8 +17,6 @@ const sign_in = async({email, password}, ctx) => {
13
17
  const {req} = ctx
14
18
 
15
19
  // find the matching user
16
- // TODO: document ctx param
17
- // const user = await User.findOne({email}, null, {ctx})
18
20
  const user = await User.findOne({email}, null)
19
21
 
20
22
  if (!user) {
@@ -26,13 +28,20 @@ const sign_in = async({email, password}, ctx) => {
26
28
  const is_match = await compare_hash(password, hashed_pass)
27
29
 
28
30
  if (is_match) {
29
- console.log("is match, user signed in wow")
31
+ log("compare_hash is match")
32
+
33
+ req.session.user_id = user._id.toString()
30
34
  await req.session.save()
31
- console.log("rb:auth:user_signed_in")
35
+
36
+ log("session saved, user is signed in")
37
+
32
38
  return {
33
39
  status: "ok"
34
40
  }
41
+
35
42
  } else {
43
+ log("no match, returning error")
44
+
36
45
  return fail()
37
46
  }
38
47
  }