[SOLVED] Onboarding users


#1

Right now I have a second step for new users signing up. This entails users providing a bit more information about themselves after the sign up with email and password. The fields are: Username, display name and a short bio. All these fields are required and I’ve bundled them into a router I call /welcome. To keep control of whether users have successfully completed this step or not I’ve just added a field to the DB / Schema called completedOnboarding: true | false. But after trying to optimize some of the routes and subscriptions I realised this isn’t really a great way to go about doing this. Because what I’m basically doing is publishing and subscribing globally (with the exception of the actual /welcome route) to additional user fields (as this shouldn’t be apart of profile, given the fact that it shouldn’t be possible for users to change this themselves), which isn’t that optimal. Any suggestions to how I can do this better? I was thinking of just using Session variables, but haven’t really given it a go beyond just tagging new users as Sessions.set(‘completedOnboarding’, false).

What I’m doing now is - publishing this:

Meteor.publish('userData', function(userId) {
	return Meteor.users.find(userId, {
			fields: {
				'completedOnboarding': 1
			}
		});
});

And then subscribing globally like this:

Router.configure({
  layoutTemplate: 'layout',
  loadingTemplate: 'loading',

  waitOn: function() {
  	return Meteor.subscribe('userData', Meteor.userId());
  }
});

#2

How about redirecting users if the bio, username, etc. is not stored? That means you could get rid of the extra field in the document. From my point of view sessions are not the best solution because every client/user could change them.


#3

That’s actually a pretty good idea. That was basically exactly the goal that I wouldn’t have to add an extra field to the Schema + specifying extra publish and subscriptions to extend user data. The great thing about this too is that I can just put the fields in profile anyways given the fact that they are user definable and just check exactly what you say if they are filled in or not. Thanks for the help!


#4

Glad I could help :slight_smile: