diff options
author | Max Wu | 2017-01-09 00:49:40 +0800 |
---|---|---|
committer | GitHub | 2017-01-09 00:49:40 +0800 |
commit | b13635aac9d42996d0ac9b9b7dcbdf94102c7abe (patch) | |
tree | 966bdbdd4a359311eae02a86144df8a4307aafb2 /lib/models | |
parent | 23a12dd927b66880fa991b377d450455851b69a9 (diff) | |
parent | 94abfaba7c5b7655eda3d6547144adfa26c90a5f (diff) |
Merge pull request #279 from alecdwm/ldap-auth
Support for LDAP server authentication
Diffstat (limited to '')
-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; }, |