diff options
author | alecdwm | 2017-01-06 05:37:40 +0100 |
---|---|---|
committer | alecdwm | 2017-01-06 05:37:40 +0100 |
commit | 01361afa7a739f05493ca4a718d6ce5ffe728bc4 (patch) | |
tree | 73c526a045829765c50e492ad1f98de09faf6c78 /lib/models | |
parent | 3491f97f7e18a811e516431fa55429f015cef8c4 (diff) |
Profile pictures for LDAP users
Diffstat (limited to 'lib/models')
-rw-r--r-- | lib/models/user.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/models/user.js b/lib/models/user.js index aaf344de..7d27242c 100644 --- a/lib/models/user.js +++ b/lib/models/user.js @@ -7,6 +7,7 @@ var scrypt = require('scrypt'); // core var logger = require("../logger.js"); +var letterAvatars = require('../letter-avatars.js'); module.exports = function (sequelize, DataTypes) { var User = sequelize.define("User", { @@ -105,6 +106,16 @@ module.exports = function (sequelize, DataTypes) { case "google": photo = profile.photos[0].value.replace(/(\?sz=)\d*$/i, '$196'); break; + case "ldap": + //no image api provided, + //use gravatar if email exists, + //otherwise generate a letter avatar + if (profile.emails[0]) { + photo = 'https://www.gravatar.com/avatar/' + md5(profile.emails[0]) + '?s=96'; + } else { + photo = letterAvatars(profile.username); + } + break; } return photo; }, |