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,36 +3,41 @@ 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')
|
||||||
.form-group
|
.row
|
||||||
label.col-xs-2.control-label(for='email') Email
|
.col-xs-2
|
||||||
.col-xs-4
|
img(src="#{user.gravatar()}")
|
||||||
input.form-control(type='email', name='email', id='email', value='#{user.email}')
|
small Change your photo at
|
||||||
.form-group
|
a(href="http://gravatar.com") Gravatar
|
||||||
label.col-xs-2.control-label(for='name') Name
|
.col-xs-10
|
||||||
.col-xs-4
|
.form-group
|
||||||
input.form-control(type='text', name='name', id='name', value='#{user.profile.name}')
|
label.col-xs-2.control-label(for='email') Email
|
||||||
.form-group
|
.col-xs-4
|
||||||
label.col-xs-2.control-label(for='name') Gender
|
input.form-control(type='email', name='email', id='email', value='#{user.email}')
|
||||||
.col-xs-4
|
.form-group
|
||||||
label.radio
|
label.col-xs-2.control-label(for='name') Name
|
||||||
input(type='radio', checked=user.profile.gender=='male', name='gender', value='male', data-toggle='radio')
|
.col-xs-4
|
||||||
| Male
|
input.form-control(type='text', name='name', id='name', value='#{user.profile.name}')
|
||||||
label.radio
|
.form-group
|
||||||
input(type='radio', checked=user.profile.gender=='female', name='gender', value='female', data-toggle='radio')
|
label.col-xs-2.control-label(for='name') Gender
|
||||||
| Female
|
.col-xs-4
|
||||||
.form-group
|
label.radio
|
||||||
label.col-xs-2.control-label(for='location') Location
|
input(type='radio', checked=user.profile.gender=='male', name='gender', value='male', data-toggle='radio')
|
||||||
.col-xs-4
|
| Male
|
||||||
input.form-control(type='text', name='location', id='location', value='#{user.profile.location}')
|
label.radio
|
||||||
.form-group
|
input(type='radio', checked=user.profile.gender=='female', name='gender', value='female', data-toggle='radio')
|
||||||
label.col-xs-2.control-label(for='website') Website
|
| Female
|
||||||
.col-xs-4
|
.form-group
|
||||||
input.form-control(type='text', name='website', id='website', value='#{user.profile.website}')
|
label.col-xs-2.control-label(for='location') Location
|
||||||
.form-group
|
.col-xs-4
|
||||||
.col-xs-offset-2.col-xs-4
|
input.form-control(type='text', name='location', id='location', value='#{user.profile.location}')
|
||||||
button.btn.btn.btn-primary(type='submit') Update Profile
|
.form-group
|
||||||
|
label.col-xs-2.control-label(for='website') Website
|
||||||
|
.col-xs-4
|
||||||
|
input.form-control(type='text', name='website', id='website', value='#{user.profile.website}')
|
||||||
|
.form-group
|
||||||
|
.col-xs-offset-2.col-xs-4
|
||||||
|
button.btn.btn.btn-primary(type='submit') Update Profile
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user