summaryrefslogtreecommitdiff
path: root/lib/models
diff options
context:
space:
mode:
Diffstat (limited to 'lib/models')
-rw-r--r--lib/models/user.js11
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;
},