sumba 0.3.0 → 0.3.2
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/bajo/helper/get-user.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
async function getUser (rec, safe = true) {
|
|
2
|
-
const { getConfig
|
|
2
|
+
const { getConfig } = this.bajo.helper
|
|
3
3
|
const { recordGet } = this.bajoDb.helper
|
|
4
|
-
const { omit,
|
|
4
|
+
const { omit, isPlainObject } = this.bajo.helper._
|
|
5
5
|
const cfg = getConfig('sumba')
|
|
6
6
|
let user
|
|
7
|
-
if (
|
|
8
|
-
else user = rec
|
|
7
|
+
if (isPlainObject(rec)) user = rec
|
|
8
|
+
else user = await recordGet('SumbaUser', rec, { noHook: true })
|
|
9
9
|
return safe ? omit(user, cfg.auth.common.omitUserFields) : user
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const bajoDbOnBeforeRecordFind = {
|
|
2
2
|
level: 1000,
|
|
3
3
|
handler: async function (coll, filter, options) {
|
|
4
|
-
const {
|
|
4
|
+
const { isSet } = this.bajo.helper
|
|
5
5
|
const { isEmpty, cloneDeep, get, set } = this.bajo.helper._
|
|
6
6
|
const { hasColumn } = this.sumba.helper
|
|
7
7
|
const item = { siteId: 'req.site.id', userId: 'req.user.id' }
|
|
8
8
|
for (const i in item) {
|
|
9
9
|
const rec = get(options, item[i])
|
|
10
|
-
if (rec && await hasColumn(i, coll)) {
|
|
10
|
+
if (isSet(rec) && await hasColumn(i, coll)) {
|
|
11
11
|
filter.query = filter.query ?? {}
|
|
12
12
|
const old = cloneDeep(filter.query.$or)
|
|
13
13
|
if (old) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export async function checker (coll, id, req) {
|
|
2
|
-
const {
|
|
2
|
+
const { error } = this.bajo.helper
|
|
3
3
|
const { recordFind } = this.bajoDb.helper
|
|
4
4
|
const { get } = this.bajo.helper._
|
|
5
5
|
const { hasColumn } = this.sumba.helper
|
|
6
6
|
const item = { siteId: 'site.id', userId: 'user.id' }
|
|
7
7
|
for (const i in item) {
|
|
8
8
|
const rec = get(req, item[i])
|
|
9
|
+
console.log(rec)
|
|
9
10
|
if (rec && await hasColumn(i, coll)) {
|
|
10
11
|
const filter = { query: { id }, limit: 1 }
|
|
11
12
|
filter.query[i] = rec
|
|
@@ -2,7 +2,6 @@ const coll = 'SumbaUser'
|
|
|
2
2
|
const hidden = ['password', 'token', 'siteId']
|
|
3
3
|
|
|
4
4
|
async function get ({ ctx }) {
|
|
5
|
-
const { importPkg } = this.bajo.helper
|
|
6
5
|
const { recordUpdate } = this.bajoWeb.helper
|
|
7
6
|
const { omit } = this.bajo.helper._
|
|
8
7
|
const { docSchemaColl } = this.bajoWebRestapi.helper
|
package/lib/check-user-id.js
CHANGED
|
@@ -49,7 +49,7 @@ async function mergeSetting (req) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
async function checkUserId (req, reply, source) {
|
|
52
|
-
const { getConfig, error
|
|
52
|
+
const { getConfig, error } = this.bajo.helper
|
|
53
53
|
const ctx = this[source].instance
|
|
54
54
|
if (!req.routeOptions.url) return
|
|
55
55
|
const { isEmpty, camelCase } = this.bajo.helper._
|