LibreChat/api/server/middleware/optionalJwtAuth.js
Yuichi Oneda aea01f0bc5
🚀 feat: Banner (#3952)
* feat: Add banner schema and model

* feat: Add optional JwtAuth

To handle the conditional logic with and without authentication within the model.

* feat: Add an endpoint to retrieve a banner

* feat: Add implementation for client to use banner and access API

* feat: Display a banner on UI

* feat: Script for updating and deleting banners

* style: Update banner style

* fix: Adjust the height when the banner is displayed

* fix: failed specs
2024-09-11 09:34:25 -04:00

17 lines
433 B
JavaScript

const passport = require('passport');
// This middleware does not require authentication,
// but if the user is authenticated, it will set the user object.
const optionalJwtAuth = (req, res, next) => {
passport.authenticate('jwt', { session: false }, (err, user) => {
if (err) {
return next(err);
}
if (user) {
req.user = user;
}
next();
})(req, res, next);
};
module.exports = optionalJwtAuth;