Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
var buf = a.buffers;
var val = a.vals;
var item;
if ( a.type == 'thumbnailPhoto' )
    item = buf;
else
    item = val;
if (item && item.length) {
    if (item.length > 1) {
        obj[a.type] = item.slice();
    } else {
        obj[a.type] = item[0];
    }
} else {
    obj[a.type] = [];
}


Then, overwrite the thumbnailPhoto attribute to be a string used in <img src='{thumbnailPhoto}'>:


Code Block
languagejs
router.post('/login',
    passport.authenticate('ldapauth'),
    (req, res) => {
        req.user.thumbnailPhoto = 'data:image/jpeg;base64,' + Buffer.from(req.user.thumbnailPhoto).toString('base64');
        res.render('profile', req.user);
    });

https://github.com/joyent/node-ldapjs/issues/137

...