Skip to content

Commit

Permalink
Prevent crash on invalid JWT
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Dec 1, 2023
1 parent c9ed5f1 commit 8029e95
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/plugins/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@ class PassportPlugin extends Passport {
passwordField: 'password',
session: false,
}, callbackify(localLogin)));
this.use('jwt', new JWTStrategy(options.secret, (user) => uw.users.getUser(user.id)));
this.use('jwt', new JWTStrategy(options.secret, async (user) => {
try {
return await uw.users.getUser(user.id);
} catch (err) {
this.#logger.warn({ err, user }, 'could not load user from JWT');
return null;
}
}));

uw.config.register(schema['uw:key'], schema);
const unsubscribe = uw.config.subscribe(schema['uw:key'], /** @param {SocialAuthSettings} settings */ (settings) => {
Expand Down

0 comments on commit 8029e95

Please sign in to comment.