aboutsummaryrefslogtreecommitdiffstats
path: root/lib/auth.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-13 21:04:02 +0000
committerAdam Soltys <[email protected]>2023-02-13 21:04:10 +0000
commit19480e0c07632b645fbee881dcbc3bf41c481eed (patch)
tree213f865c1747659779f496f296371766e893aef5 /lib/auth.js
parentf7307a8e2d627006dd6e72fe9c1e2e4d5c6e312a (diff)
downloadcoinos-server-19480e0c07632b645fbee881dcbc3bf41c481eed.tar.gz
coinos-server-19480e0c07632b645fbee881dcbc3bf41c481eed.zip
check payload id
Diffstat (limited to 'lib/auth.js')
-rw-r--r--lib/auth.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/auth.js b/lib/auth.js
index 2e26f138..0533de31 100644
--- a/lib/auth.js
+++ b/lib/auth.js
@@ -34,8 +34,12 @@ export const jwtStrategy = new jwt.Strategy(
secretOrKey: config.jwt
},
async (payload, next) => {
- let user = await g(`user:${payload.id}`);
- if (typeof user === "string") await g(`user:${user}`);
+ let user;
+ if (payload.id) {
+ user = await g(`user:${payload.id}`);
+ if (typeof user === "string") await g(`user:${user}`);
+ }
+
next(null, user);
}
);