diff --git a/imports/api/auth/methods.js b/imports/api/auth/methods.js index 4d4e4e9..1952c64 100644 --- a/imports/api/auth/methods.js +++ b/imports/api/auth/methods.js @@ -10,10 +10,11 @@ MeteorAccounts.onCreateUser(function(options, user) { var account = {owner: user._id}; //Inserting default bank account on signup Accounts.insert({owner: account.owner, bank: 'bank-Default', country: 'PK', purpose: 'Bank Account', icon: 'abc' }); - //Reset user object + // Reset user object if (options.profile) user.profile = options.profile; - user.profile.md5hash = Gravatar.hash( user.emails[0].address ); + if(user.emails && user.emails.length) + user.profile.md5hash = Gravatar.hash(user.emails[0].address); return user; }); \ No newline at end of file diff --git a/imports/startup/server/fixtures.js b/imports/startup/server/fixtures.js index a565222..e0ec96d 100755 --- a/imports/startup/server/fixtures.js +++ b/imports/startup/server/fixtures.js @@ -8,9 +8,7 @@ import { Accounts } from '../../api/accounts/accounts.js'; function setGravatars() { let users = Meteor.users.find( { md5hash: { $exists: false } } ); users.forEach( ( user ) => { - console.log("user"); - console.log(user); - if(user.emails.length) + if(user.emails && user.emails.length) Meteor.users.update( { _id: user._id }, { $set: { "profile.md5hash": Gravatar.hash( user.emails[0].address ) } }); diff --git a/imports/ui/components/AppLayout.jsx b/imports/ui/components/AppLayout.jsx index 81611a4..319a3b4 100755 --- a/imports/ui/components/AppLayout.jsx +++ b/imports/ui/components/AppLayout.jsx @@ -50,14 +50,20 @@ export default class AppLayout extends Component { }) } render() { - let {props} = this; + let {props} = this, gravatar, user = Meteor.user(); props = {...props, name: this.name, toggleDrawerActive: this.toggleDrawerActive.bind(this), drawerActive: this.state.drawerActive }; - if(Meteor.user && Meteor.user().profile.md5hash){ - var gravatar = Gravatar.imageUrl( Meteor.user().profile.md5hash, { secure: true, size: "48", d: 'mm', rating: 'pg' } );} + if(user && user.profile.md5hash) { + gravatar = Gravatar.imageUrl(user.profile.md5hash, { + secure: true, + size: "48", + d: 'mm', + rating: 'pg' + }); + } return ( @@ -65,7 +71,7 @@ export default class AppLayout extends Component {
- Welcome {this.name()} + Welcome {this.name()}