mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 22:54:42 -04:00
Profile pictures for LDAP users
This commit is contained in:
parent
3491f97f7e
commit
01361afa7a
3 changed files with 35 additions and 0 deletions
|
@ -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;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue