@paralect/hive 0.1.32 → 0.1.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paralect/hive",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -0,0 +1,9 @@
1
+
2
+ const middleware = async (ctx, next) => {
3
+ ctx.state.isAllowAnonymous = true;
4
+ return next();
5
+ };
6
+
7
+ middleware.runOrder = -1;
8
+
9
+ export default middleware;
@@ -8,7 +8,7 @@ const storeTokenToState = async (ctx) => {
8
8
  let accessToken = ctx.cookies.get('access_token');
9
9
 
10
10
  const { authorization } = ctx.headers;
11
-
11
+
12
12
  if (!accessToken && authorization) {
13
13
  accessToken = authorization.replace('Bearer', '').trim();
14
14
  }
@@ -46,6 +46,10 @@ export default async (ctx, next) => {
46
46
  return next();
47
47
  }
48
48
 
49
+ if (ctx.state.isAllowAnonymous) {
50
+ return next();
51
+ }
52
+
49
53
  ctx.status = 401;
50
54
  ctx.body = {};
51
55
  return null;