middlewares/auth.js
// Override the authorization header with password that is in the body of the request if basic auth was not supplied.
Override the authorization header with password that is in the body of the request if basic auth was not supplied.
Override the authorization header with password that is in the body of the request if basic auth was not supplied .
function convertReqBodyToBasicAuth(req, res, next) {
  if (req.body.password && !req.headers.authorization) {
    const password = b64encode(req.body.password);
    req.headers.authorization = 'Basic ' + Buffer.from(SYSTEM_USER + ':' + password).toString('base64');
  }
  next();
}
function convertReqBodyToBasicAuth ( req , res , next ) { if ( req . body . password && ! req . headers . authorization ) { const password = b64encode ( req . body . password ) ; req . headers . authorization = 'Basic ' + Buffer . from ( SYSTEM_USER + ':' + password ) . toString ( 'base64' ) ; } next ( ) ; }
Override the authorization header with password that is in the body of the request if basic auth was not supplied.
Override the authorization header with password that is in the body of the request if basic auth was not supplied .
// We need to Base64 encode because Passport breaks on ":" characters