UNPKG

@fdm-monster/server

Version:

FDM Monster is a bulk OctoPrint, Klipper, PrusaLink and BambuLab manager to set up, configure and monitor 3D printers. Our aim is to provide neat overview over your farm.

24 lines (23 loc) 772 B
import { Strategy } from "passport-jwt"; //#region src/middleware/socketio.middleware.ts const authorize = (settingsStore, options, logger, verify) => { const strategy = new Strategy(options, verify); return async function authorizeCallback(socket, next) { if (!await settingsStore.getLoginRequired()) return next(); strategy.success = function success(_user) { next(); }; strategy.fail = (info) => { logger.warn(`Failure authenticating SocketIO user, reason: '${info}'`, { reason: info }); next(new Error(info)); }; strategy.error = (error) => { logger.warn("Error authenticating SocketIO user"); next(error); }; strategy.authenticate(socket, {}); }; }; //#endregion export { authorize }; //# sourceMappingURL=socketio.middleware.js.map