mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
Merge pull request #491 from bengott/email_hash-fix
Fix email_hash bug (Issue #393)
This commit is contained in:
commit
6ccf7d7d47
5 changed files with 16 additions and 12 deletions
|
@ -32,7 +32,6 @@ mrt:moment
|
|||
mrt:mailchimp
|
||||
|
||||
cmather:handlebars-server@0.2.0
|
||||
tmeasday:crypto-md5@3.1.2
|
||||
sacha:spin@2.0.4
|
||||
sacha:juice
|
||||
chuangbo:marked@0.3.3
|
||||
|
@ -42,6 +41,7 @@ matb33:collection-hooks
|
|||
djedi:sanitize-html
|
||||
rajit:bootstrap3-datepicker
|
||||
bengott:avatar
|
||||
jparker:gravatar
|
||||
|
||||
# Telescope Packages
|
||||
|
||||
|
|
|
@ -118,8 +118,6 @@ telescope-theme-base@0.0.0
|
|||
telescope-theme-hubble@0.0.0
|
||||
telescope-update-prompt@0.1.0
|
||||
templating@1.0.7
|
||||
tmeasday:crypto-base@3.1.2
|
||||
tmeasday:crypto-md5@3.1.2
|
||||
tracker@1.0.2
|
||||
twitter@1.1.0
|
||||
ui@1.0.3
|
||||
|
|
|
@ -44,12 +44,13 @@ Template[getTemplate('user_edit')].events({
|
|||
|
||||
var $target=$(e.target);
|
||||
var name = $target.find('[name=name]').val();
|
||||
var email = $target.find('[name=email]').val();
|
||||
var user = this;
|
||||
var update = {
|
||||
"profile.name": name,
|
||||
"profile.slug": slugify(name),
|
||||
"profile.bio": $target.find('[name=bio]').val(),
|
||||
"profile.email": $target.find('[name=email]').val(),
|
||||
"profile.email": email,
|
||||
"profile.twitter": $target.find('[name=twitter]').val(),
|
||||
"profile.github": $target.find('[name=github]').val(),
|
||||
"profile.site": $target.find('[name=site]').val(),
|
||||
|
@ -84,7 +85,7 @@ Template[getTemplate('user_edit')].events({
|
|||
});
|
||||
});
|
||||
|
||||
Meteor.call('setEmailHash', user);
|
||||
Meteor.call('changeEmail', email);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ getEmail = function(user){
|
|||
};
|
||||
getEmailHash = function(user){
|
||||
// has to be this way to work with Gravatar
|
||||
return CryptoJS.MD5(getEmail(user).trim().toLowerCase()).toString()
|
||||
return Gravatar.hash(getEmail(user));
|
||||
};
|
||||
getAvatarUrl = function(user) {
|
||||
console.warn('FUNCTION getAvatarUrl() IS DEPRECATED -- package bengott:avatar is used instead.')
|
||||
|
|
|
@ -92,8 +92,17 @@ Accounts.onCreateUser(function(options, user){
|
|||
|
||||
|
||||
Meteor.methods({
|
||||
changeEmail: function(newEmail) {
|
||||
Meteor.users.update(Meteor.userId(), {$set: {emails: [{address: newEmail}]}});
|
||||
changeEmail: function (newEmail) {
|
||||
Meteor.users.update(
|
||||
Meteor.userId(),
|
||||
{$set: {
|
||||
emails: [{address: newEmail}],
|
||||
email_hash: Gravatar.hash(newEmail),
|
||||
// Just in case this gets called from somewhere other than /client/views/users/user_edit.js
|
||||
"profile.email": newEmail
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
numberOfPostsToday: function(){
|
||||
console.log(numberOfItemsInPast24Hours(Meteor.user(), Posts));
|
||||
|
@ -110,9 +119,5 @@ Meteor.methods({
|
|||
var ageInHours = (new Date().getTime() - object.submitted) / (60 * 60 * 1000);
|
||||
var newScore = baseScore / Math.pow(ageInHours + 2, 1.3);
|
||||
return Math.abs(object.score - newScore);
|
||||
},
|
||||
setEmailHash: function(user){
|
||||
var hash = getEmailHash(user);
|
||||
Meteor.users.update(user._id, {$set : {email_hash : hash}});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue