@bee.js/node 0.0.31 → 0.0.35
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/beehive.js +3 -0
- package/lib/JWT/beeJWT.js +11 -4
- package/package.json +1 -1
package/beehive.js
CHANGED
|
@@ -378,6 +378,9 @@ module.exports = function hive(req = {}, res = {}, model = null) {
|
|
|
378
378
|
|
|
379
379
|
SQL = 'DELETE FROM ' + q(model.table)
|
|
380
380
|
SQL += beeORM.modelSqlWhere(model, ids, req.middleware)
|
|
381
|
+
SQL += script[0]['where'].length
|
|
382
|
+
? (!ids.length ? ' WHERE ' : ' AND ') + script[0]['where'].join(" AND ")
|
|
383
|
+
: ''
|
|
381
384
|
|
|
382
385
|
data = await dbExec(SQL)
|
|
383
386
|
|
package/lib/JWT/beeJWT.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
const crypto = require('crypto')
|
|
2
2
|
const log = require('../beeHive/log')
|
|
3
3
|
|
|
4
|
-
module.exports = function token(
|
|
4
|
+
module.exports = function token(_payload = null, header = {}) {
|
|
5
5
|
|
|
6
|
-
if(
|
|
6
|
+
if(_payload) {
|
|
7
|
+
|
|
8
|
+
let { jwt, ...payload } = _payload
|
|
7
9
|
|
|
8
10
|
if(!global.configs.jwt && !global.configs.jwt.secret) return log("ERROR: no jwt.secret defined in configs.")
|
|
9
11
|
|
|
@@ -32,8 +34,13 @@ module.exports = function token(payload = null, header = {}) {
|
|
|
32
34
|
.update(`${header}.${payload}`)
|
|
33
35
|
.digest("base64")
|
|
34
36
|
|
|
35
|
-
this.data.jwt
|
|
36
|
-
|
|
37
|
+
this.data.jwt = this.data.jwt ? [this.data.jwt] : this.data.jwt
|
|
38
|
+
|
|
39
|
+
this.data.jwt = !this.data.jwt
|
|
40
|
+
? `${header}.${payload}.${signature}`
|
|
41
|
+
: this.data.jwt.concat(`${header}.${payload}.${signature}`)
|
|
42
|
+
|
|
43
|
+
this.counters.jwt = (this.counters.jwt||0) + 1
|
|
37
44
|
|
|
38
45
|
log("JWT created: " + this.data.jwt)
|
|
39
46
|
|