@abtnode/blocklet-services 1.8.17 → 1.8.18

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.
@@ -2,6 +2,7 @@
2
2
  const get = require('lodash/get');
3
3
  const minimatch = require('minimatch');
4
4
  const bearerToken = require('express-bearer-token');
5
+ const getBlocklet403Template = require('@abtnode/router-templates/lib/blocklet-403');
5
6
 
6
7
  const validators = require('@blocklet/sdk/lib/validators');
7
8
  const {
@@ -186,12 +187,22 @@ const init = ({ node, options }) => {
186
187
 
187
188
  if (blocked) {
188
189
  if (!authenticated) {
189
- res.redirect(getRedirectUrl({ req, pagePath: '/login' }));
190
+ if (req.accepts(['html', 'json']) === 'html') {
191
+ res.redirect(getRedirectUrl({ req, pagePath: '/login' }));
192
+ } else {
193
+ res.status(401).json({ code: 401, error: 'Unauthorized' });
194
+ }
190
195
  return;
191
196
  }
192
197
 
193
198
  if (!authorized) {
194
- res.status(403).json({ code: 'forbidden', error: 'not allowed' });
199
+ if (req.accepts(['html', 'json']) === 'html') {
200
+ const nodeInfo = await req.getNodeInfo();
201
+ const blocklet = await req.getBlocklet();
202
+ res.send(getBlocklet403Template(blocklet, nodeInfo));
203
+ } else {
204
+ res.status(403).json({ code: 403, error: 'Forbidden' });
205
+ }
195
206
  return;
196
207
  }
197
208
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.17",
6
+ "version": "1.8.18",
7
7
  "description": "Provide unified services for every blocklet",
8
8
  "main": "api/index.js",
9
9
  "files": [
@@ -31,23 +31,23 @@
31
31
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
32
32
  "license": "MIT",
33
33
  "dependencies": {
34
- "@abtnode/auth": "1.8.17",
35
- "@abtnode/client": "1.8.17",
36
- "@abtnode/constant": "1.8.17",
37
- "@abtnode/core": "1.8.17",
38
- "@abtnode/cron": "1.8.17",
39
- "@abtnode/db": "1.8.17",
40
- "@abtnode/logger": "1.8.17",
41
- "@abtnode/router-adapter": "1.8.17",
42
- "@abtnode/router-templates": "1.8.17",
43
- "@abtnode/util": "1.8.17",
34
+ "@abtnode/auth": "1.8.18",
35
+ "@abtnode/client": "1.8.18",
36
+ "@abtnode/constant": "1.8.18",
37
+ "@abtnode/core": "1.8.18",
38
+ "@abtnode/cron": "1.8.18",
39
+ "@abtnode/db": "1.8.18",
40
+ "@abtnode/logger": "1.8.18",
41
+ "@abtnode/router-adapter": "1.8.18",
42
+ "@abtnode/router-templates": "1.8.18",
43
+ "@abtnode/util": "1.8.18",
44
44
  "@arcblock/did-auth": "1.17.19",
45
45
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
46
46
  "@arcblock/event-hub": "1.17.19",
47
47
  "@arcblock/jwt": "1.17.19",
48
48
  "@arcblock/ws": "1.17.19",
49
- "@blocklet/meta": "1.8.17",
50
- "@blocklet/sdk": "1.8.17",
49
+ "@blocklet/meta": "1.8.18",
50
+ "@blocklet/sdk": "1.8.18",
51
51
  "@did-connect/authenticator": "^2.1.13",
52
52
  "@did-connect/relay-adapter-express": "^2.1.13",
53
53
  "@did-connect/storage-nedb": "^2.1.13",
@@ -76,7 +76,7 @@
76
76
  "url-join": "^4.0.1"
77
77
  },
78
78
  "devDependencies": {
79
- "@abtnode/ux": "1.8.17",
79
+ "@abtnode/ux": "1.8.18",
80
80
  "@arcblock/did-connect": "^2.4.23",
81
81
  "@arcblock/icons": "^2.4.23",
82
82
  "@arcblock/ux": "^2.4.23",
@@ -134,5 +134,5 @@
134
134
  "url": "https://github.com/ArcBlock/blocklet-server/issues",
135
135
  "email": "shijun@arcblock.io"
136
136
  },
137
- "gitHead": "aa1854b3b71a6250182bfcad794235099f38a514"
137
+ "gitHead": "7d82c570913bedf740afca15c27ef10d05aa85fc"
138
138
  }