add gravatar to profile

This commit is contained in:
Daniel Mills
2014-02-03 17:50:47 -05:00
parent 911cbf5685
commit f5ecfc507c
2 changed files with 41 additions and 29 deletions

View File

@ -1,5 +1,6 @@
var mongoose = require('mongoose');
var bcrypt = require('bcrypt-nodejs');
var crypto = require('crypto');
var userSchema = new mongoose.Schema({
email: { type: String, unique: true },
@ -48,4 +49,10 @@ userSchema.methods.comparePassword = function(candidatePassword, cb) {
});
};
userSchema.methods.gravatar = function() {
var md5 = crypto.createHash('md5');
md5.update(this.email);
return 'https://gravatar.com/avatar/' + md5.digest('hex').toString() + '?s=200';
};
module.exports = mongoose.model('User', userSchema);

View File

@ -3,8 +3,13 @@ extends ../layout
block content
.page-header
h3 Profile Information
form.form-horizontal(action='/account/profile', method='POST')
.row
.col-xs-2
img(src="#{user.gravatar()}")
small Change your photo at
a(href="http://gravatar.com") Gravatar
.col-xs-10
.form-group
label.col-xs-2.control-label(for='email') Email
.col-xs-4