abler-api 0.1.47 → 0.1.48
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/dist/cjs/pp-util.js +11 -5
- package/package.json +1 -1
package/dist/cjs/pp-util.js
CHANGED
|
@@ -50,7 +50,10 @@ class apiUtil$2 {
|
|
|
50
50
|
static testFlag = ppUtil$4.newGuid();
|
|
51
51
|
static envId_dev = "?";
|
|
52
52
|
static _validateBasicAuth = function (userName, password) {
|
|
53
|
-
throw
|
|
53
|
+
throw {
|
|
54
|
+
status: 500,
|
|
55
|
+
message: 'no basic auth validator'
|
|
56
|
+
};
|
|
54
57
|
}; // static apiCallRecSaver;
|
|
55
58
|
|
|
56
59
|
static config(appConfig, appErrCfg, appDbSql) {
|
|
@@ -1424,19 +1427,22 @@ class apiUtil$2 {
|
|
|
1424
1427
|
return res.sendStatus(401);
|
|
1425
1428
|
}
|
|
1426
1429
|
|
|
1427
|
-
if (!apiUtil$2._validateBasicAuth(authorization.name, authorization.pass)) {
|
|
1430
|
+
if (!(await apiUtil$2._validateBasicAuth(authorization.name, authorization.pass))) {
|
|
1428
1431
|
res.set('WWW-Authenticate', 'Basic realm=invalid username or password');
|
|
1429
1432
|
return res.sendStatus(401);
|
|
1430
1433
|
}
|
|
1431
1434
|
} catch (e) {
|
|
1432
|
-
if (e.
|
|
1435
|
+
if (e.status === 401) {
|
|
1433
1436
|
try {
|
|
1434
1437
|
res.set('WWW-Authenticate', `Basic realm=${e.message}`);
|
|
1435
1438
|
return res.sendStatus(401);
|
|
1436
|
-
} catch {
|
|
1439
|
+
} catch {
|
|
1440
|
+
res.set('WWW-Authenticate', 'Basic realm=validate fail');
|
|
1441
|
+
return res.status(401).send(e);
|
|
1442
|
+
}
|
|
1437
1443
|
}
|
|
1438
1444
|
|
|
1439
|
-
return res.
|
|
1445
|
+
return res.status(e.status || 500).send(e);
|
|
1440
1446
|
}
|
|
1441
1447
|
|
|
1442
1448
|
return next();
|