add gravatar to profile
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
var mongoose = require('mongoose');
|
var mongoose = require('mongoose');
|
||||||
var bcrypt = require('bcrypt-nodejs');
|
var bcrypt = require('bcrypt-nodejs');
|
||||||
|
var crypto = require('crypto');
|
||||||
|
|
||||||
var userSchema = new mongoose.Schema({
|
var userSchema = new mongoose.Schema({
|
||||||
email: { type: String, unique: true },
|
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);
|
module.exports = mongoose.model('User', userSchema);
|
||||||
|
@ -3,8 +3,13 @@ extends ../layout
|
|||||||
block content
|
block content
|
||||||
.page-header
|
.page-header
|
||||||
h3 Profile Information
|
h3 Profile Information
|
||||||
|
|
||||||
form.form-horizontal(action='/account/profile', method='POST')
|
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
|
.form-group
|
||||||
label.col-xs-2.control-label(for='email') Email
|
label.col-xs-2.control-label(for='email') Email
|
||||||
.col-xs-4
|
.col-xs-4
|
||||||
|
Reference in New Issue
Block a user