import { authenticate } from 'passport' ; export default function passportLoginMiddleware ( req , res , next ) { const authFunction = authenticate ( 'local' , { session : false } ) ; authFunction ( req , res , ( err ) => { if ( err ) { res . status ( 401 ) . json ( err ) ; return next ( err ) ; } return next ( null ) ; } ) ; }