abler-api 0.1.46 → 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 +16 -4
- 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,13 +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
|
-
|
|
1433
|
-
|
|
1435
|
+
if (e.status === 401) {
|
|
1436
|
+
try {
|
|
1437
|
+
res.set('WWW-Authenticate', `Basic realm=${e.message}`);
|
|
1438
|
+
return res.sendStatus(401);
|
|
1439
|
+
} catch {
|
|
1440
|
+
res.set('WWW-Authenticate', 'Basic realm=validate fail');
|
|
1441
|
+
return res.status(401).send(e);
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
return res.status(e.status || 500).send(e);
|
|
1434
1446
|
}
|
|
1435
1447
|
|
|
1436
1448
|
return next();
|