corebasic 1.0.146 → 1.0.147
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/libs/auth.js +1 -1
- package/libs/dip.js +2 -2
- package/package.json +1 -1
package/libs/auth.js
CHANGED
|
@@ -58,7 +58,7 @@ async function attemptLogin(req, res) {
|
|
|
58
58
|
let otp = mob === '0123456789' ? '1234' : otpGenerator.generate(4, { upperCaseAlphabets: false, specialChars: false, digital: true, lowerCaseAlphabets: false });
|
|
59
59
|
if (mob === '0123456789' || await sendOtp(mob, otp, req.body.app)) {
|
|
60
60
|
let userId = req.body.userId ?? Utils.uid()
|
|
61
|
-
let now = Utils.now().
|
|
61
|
+
let now = Utils.now().getTime()
|
|
62
62
|
let data = req.body.data ?? {}
|
|
63
63
|
let info = { clientId, created: now, updated: now, ...data}
|
|
64
64
|
await Dip.update(meta, collection, { _id: mob }, { $set: { otp, clientId, time, updated: now, attemptLogin: true }, $setOnInsert: { _id: mob, otp, time, userId, ...info } }, { upsert: true })
|
package/libs/dip.js
CHANGED
|
@@ -30,7 +30,7 @@ export const IdempotentDip = () => {
|
|
|
30
30
|
new: (async function (meta, txn, blank) {
|
|
31
31
|
this.txn = txn
|
|
32
32
|
this.meta = meta
|
|
33
|
-
return blank ? this : (await Elabase.query(this.meta, "txns",{_id: this.txn}).length ? false : this)
|
|
33
|
+
return blank ? this : ((await Elabase.query(this.meta, "txns",{_id: this.txn})).length ? false : this)
|
|
34
34
|
}),
|
|
35
35
|
insert: (async function (collection, query, data) {
|
|
36
36
|
await Elabase.update(this.meta, collection, query, { $setOnInsert: data }, {upsert: true})
|
|
@@ -39,7 +39,7 @@ export const IdempotentDip = () => {
|
|
|
39
39
|
let token = { [this.txn]: true }
|
|
40
40
|
let idempotent = { [this.txn]: { $exists: rollback ?? false } }
|
|
41
41
|
let result = await Elabase.update(this.meta, collection, {...query, ...idempotent}, {...data, $setOnInsert: undefined, $set: {...(data.$set ?? {}), ...token} })
|
|
42
|
-
return result.count ? true : await Elabase.query(this.meta, collection, {...query, ...idempotent}).length
|
|
42
|
+
return result.count ? true : (await Elabase.query(this.meta, collection, {...query, ...idempotent})).length
|
|
43
43
|
}),
|
|
44
44
|
upsert: (async function (collection, query, data, rollback) {
|
|
45
45
|
await this.insert(collection, query, data.$setOnInsert)
|