Page creating an account driver http: // localhost: 3000 / driver / join method called /imports/api/users/methods.js= >
createDriver (), which should normally assign the CONST.USER_ROLES.DRIVER role for this new account , but following the creation account , http: // localhost: 3000 / s / driver / vehicles ( / imports / ui / pages /driver-vehicles.html ) is not displayed due to the
precondition if (! Helpers.isDriver ()) in /imports/startup/client/router.js router
You can’t create your own custom fields at the root level of the user object. What I mean is, something like this wouldn’t work:
Accounts.createUser({
email: 'test@test.com', // this is OK
password: 'test', // this is OK
firstName: 'Person', // this is not OK
roles: SOME_VALUE, // this is not OK
profile: {
anyPropertiesWithinProfileAreOk: true,
},
});
Except using profile
is not recommended, so I’ve created a hook that will let me create a user with items in profile
, but it will move them to the root level upon user creation:
Accounts.onCreateUser((options, user) => {
/*
* The official Meteor Guide recommends not storing things in user.profile. So
* this will mutate any newly created user and just put profile information at
* the root level which is recommended. So when using Accounts.createUser,
* go ahead and use profile, and this will handle fixing it.
*
* Reference: http://guide.meteor.com/accounts.html#dont-use-profile
*/
return { ...user, ...options.profile };
});
Now I can do things like this:
Accounts.createUser({ email: 'test@test.com', password: 'test', profile: { firstName: 'Person' } });
And the hook above will move firstName
to the root level.