corebasic 1.0.169 → 1.0.171
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 +5 -3
- package/package.json +1 -1
package/libs/auth.js
CHANGED
|
@@ -38,7 +38,7 @@ async function attemptLogin(req, res) {
|
|
|
38
38
|
|
|
39
39
|
let expiry = 300000
|
|
40
40
|
let userMob = req.body.mob ?? req.body.phone
|
|
41
|
-
let mob = userMob
|
|
41
|
+
let mob = userMob.endsWith('0123456789') ? '0123456789' : Utils.parseMob(userMob)
|
|
42
42
|
let time = new Date().getTime()
|
|
43
43
|
let collection = (req.body.app ? req.body.app + '.' : '') + "auth.login"
|
|
44
44
|
let errMessage = {success: false, message: "Login Server Error"}
|
|
@@ -56,7 +56,7 @@ async function attemptLogin(req, res) {
|
|
|
56
56
|
throw {...errMessage, mode: 'verify', info: "Invalid/Expired OTP"}
|
|
57
57
|
} else { // generate login
|
|
58
58
|
let otp = mob === '0123456789' ? '1234' : otpGenerator.generate(4, { upperCaseAlphabets: false, specialChars: false, digital: true, lowerCaseAlphabets: false });
|
|
59
|
-
if (mob === '0123456789' || await sendOtp(mob, otp, req.body.app)) {
|
|
59
|
+
if (mob === '0123456789' || await sendOtp(mob, otp, req.body.app, req.body.hash)) {
|
|
60
60
|
let userId = req.body.userId ?? Utils.uid()
|
|
61
61
|
let now = Utils.now().getTime()
|
|
62
62
|
let data = req.body.data ?? {}
|
|
@@ -70,8 +70,10 @@ async function attemptLogin(req, res) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
async function sendOtp(mob, otp, app) {
|
|
73
|
+
async function sendOtp(mob, otp, app, hash) {
|
|
74
74
|
try {
|
|
75
|
+
if (app && hash)
|
|
76
|
+
app = encodeURIComponent(`${app} (#${hash})`) // Of the form '<app> (#<hash>)' for better readability. Note: Axios works with SlypBusiness%20(%23<HASH>) but Curl requires SlypBusiness%20%28%23<HASH>%29
|
|
75
77
|
let api = process.env.SMS_API.replace(':phone', mob).replace(':otp', otp).replace(':app', app ?? 'app')
|
|
76
78
|
await axios.get(api)
|
|
77
79
|
return true
|