Skip to content

Commit

Permalink
User image implementation after some bug fixes issue # 44
Browse files Browse the repository at this point in the history
  • Loading branch information
Syed Asher Ahmed committed Mar 29, 2017
1 parent c45e8b3 commit f47733d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions imports/api/auth/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

});
4 changes: 1 addition & 3 deletions imports/startup/server/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) }
});
Expand Down
14 changes: 10 additions & 4 deletions imports/ui/components/AppLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,28 @@ 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 (
<Layout>
<LeftMenu {...props}/>
<Panel>
<AppBarExtended>
<IconButton icon='menu' accent inverse={ true } onClick={ this.toggleDrawerActive.bind(this) }/>
<div className={theme.headerGreeting}>
<span>Welcome <b>{this.name()}</b> <img src = {this.state.avatar ? this.state.avatar : gravatar } width="45" height="45" /><i className="material-icons" onClick={this.logout.bind(this)}>&#xE8AC;</i></span>
<span>Welcome <b>{this.name()}</b> <img src = {this.state.avatar || gravatar || "/assets/images/HQ3YU7n.gif" } width="45" height="45" /><i className="material-icons" onClick={this.logout.bind(this)}>&#xE8AC;</i></span>
</div>
</AppBarExtended>
<div className="page-content-wrapper" style={{ flex: 1, display: 'flex' }}>
Expand Down

0 comments on commit f47733d

Please sign in to comment.