@loomcore/api 0.2.22 → 0.2.23

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.
@@ -50,29 +50,19 @@ const isAuthorized = (config) => {
50
50
  throw new UnauthenticatedError();
51
51
  }
52
52
  const authConfig = getAuthConfig();
53
- try {
54
- const rawPayload = jwt.verify(token, authConfig.clientSecret);
55
- const userContext = getAuthUserContextSpec().decode(rawPayload);
56
- req.userContext = userContext;
57
- if (isAdmin(userContext)) {
58
- next();
59
- return;
60
- }
61
- const method = resolveAuthMethod(req);
62
- if (!method) {
63
- throw new UnauthorizedError();
64
- }
65
- assertFeatureRequirement(userContext, config[method]);
53
+ const rawPayload = jwt.verify(token, authConfig.clientSecret);
54
+ const userContext = getAuthUserContextSpec().decode(rawPayload);
55
+ req.userContext = userContext;
56
+ if (isAdmin(userContext)) {
66
57
  next();
58
+ return;
67
59
  }
68
- catch (err) {
69
- if (err instanceof UnauthorizedError ||
70
- err instanceof UnauthenticatedError) {
71
- throw err;
72
- }
73
- console.error(err);
74
- throw new UnauthenticatedError();
60
+ const method = resolveAuthMethod(req);
61
+ if (!method) {
62
+ throw new UnauthorizedError();
75
63
  }
64
+ assertFeatureRequirement(userContext, config[method]);
65
+ next();
76
66
  };
77
67
  };
78
68
  export { isAuthorized };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcore/api",
3
- "version": "0.2.22",
3
+ "version": "0.2.23",
4
4
  "private": false,
5
5
  "description": "Loom Core Api - An opinionated Node.js api using Typescript, Express, and MongoDb or PostgreSQL",
6
6
  "scripts": {