server/middleware/auth.js
function loadUsrInfo(token, app, zlSite, next) {
  app.models.zlUser.findById(token.userId, (err, usr) => {
    if (err) next(err);
    else if (usr) {
      zlSite.user = _.cloneDeep(usr);
      if (!zlSite.user.usrPhoto && zlSite.user.email) {
        // use gravatar
        let graHash = md5(zlSite.user.email.toLowerCase());
        zlSite.user.usrPhoto = `https://www.gravatar.com/avatar/${graHash}?s=100&d=mm`
      }
      next();
    }
    else {
      // user must no longer exist
      next();
    }
  });
}
function loadUsrInfo(token, app, zlSite, next) {
  app.models.zlUser.findById(token.userId, (err, usr) => {
    if (err) next(err);
    else if (usr) {
      zlSite.user = _.cloneDeep(usr);
      if (!zlSite.user.usrPhoto && zlSite.user.email) {
        // use gravatar
        let graHash = md5(zlSite.user.email.toLowerCase());
        zlSite.user.usrPhoto = `https://www.gravatar.com/avatar/${graHash}?s=100&d=mm`
      }
      next();
    }
    else {
      // user must no longer exist
      next();
    }
  });
}
function loadUsrInfo ( token , app , zlSite , next ) { app . models . zlUser . findById ( token . userId , ( err , usr ) => { if ( err ) next ( err ) ; else if ( usr ) { zlSite . user = _ . cloneDeep ( usr ) ; if ( ! zlSite . user . usrPhoto && zlSite . user . email ) { // use gravatar let graHash = md5 ( zlSite . user . email . toLowerCase ( ) ) ; zlSite . user . usrPhoto = ` ${ graHash } ` } next ( ) ; } else { // user must no longer exist next ( ) ; } } ) ; }
load user details into variable
load user details into variable