diff options
| author | Adam Soltys <[email protected]> | 2023-02-13 21:04:02 +0000 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-02-13 21:04:10 +0000 |
| commit | 19480e0c07632b645fbee881dcbc3bf41c481eed (patch) | |
| tree | 213f865c1747659779f496f296371766e893aef5 /lib | |
| parent | f7307a8e2d627006dd6e72fe9c1e2e4d5c6e312a (diff) | |
| download | coinos-server-19480e0c07632b645fbee881dcbc3bf41c481eed.tar.gz coinos-server-19480e0c07632b645fbee881dcbc3bf41c481eed.zip | |
check payload id
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/auth.js | 8 |
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); } ); |
