Skip to content
13 changes: 13 additions & 0 deletions imports/api/users/server/publications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Meteor } from 'meteor/meteor';

Meteor.publish('users.info', function userInfoPublish() {
if (!this.userId) {
return this.ready();
}

return Meteor.users.find(this.userId, {
fields: {
name: 1,
},
});
});
1 change: 1 addition & 0 deletions imports/modules/get-tracker-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ const getTrackerLoader = reactiveMapper => (
);

export default getTrackerLoader;

16 changes: 16 additions & 0 deletions imports/startup/server/accounts/on-create-user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Accounts } from 'meteor/accounts-base';

Accounts.onCreateUser((options, user) => {
const profile = options.profile;
const newUser = user;

if (profile) {
newUser.name = { first: profile.name.first, last: profile.name.last };
}

if (options.email !== 'admin@admin.com') {
newUser.roles = ['registered'];
}

return newUser;
});
1 change: 1 addition & 0 deletions imports/startup/server/api.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import '../../api/documents/methods.js';
import '../../api/documents/server/publications.js';
import '../../api/users/server/publications.js';
1 change: 1 addition & 0 deletions imports/startup/server/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import './accounts/email-templates';
import './accounts/on-create-user';
import './browser-policy';
import './fixtures';
import './api';
5 changes: 4 additions & 1 deletion imports/ui/components/AppNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ AppNavigation.propTypes = {
};

export default container((props, onData) => {
onData(null, { hasUser: Meteor.user() });
const subscription = Meteor.subscribe('users.info');
if (subscription.ready()) {
onData(null, { hasUser: Meteor.user() });
}
}, AppNavigation);
2 changes: 1 addition & 1 deletion imports/ui/components/AuthenticatedNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Meteor } from 'meteor/meteor';

const userName = () => {
const user = Meteor.user();
const name = user && user.profile ? user.profile.name : '';
const name = user ? user.name : '';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just small fix
const name = user ? user.profile.name : '';

return user ? `${name.first} ${name.last}` : '';
};

Expand Down
2 changes: 1 addition & 1 deletion imports/ui/pages/Index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Index = () => (
<h2>Base</h2>
<p>A starting point for Meteor applications.</p>
<p><a className="btn btn-success" href="https://themeteorchef.com/base" role="button">Read the Documentation</a></p>
<p style={ { fontSize: '16px', color: '#aaa' } }>Currently at v4.14.0</p>
<p style={ { fontSize: '16px', color: '#aaa' } }>Currently at v4.15.0</p>
</Jumbotron>
</div>
);
Expand Down