It surely makes sense :). I think the best way would be for you to start wit a ‘create app’ which I suppose you do already.
From all my heart I say…just do React instead of templates … but this is personal opinion.
Simply put, you need to have these (‘app’ is your root folder):
app/client
app/client/main.css
app/client/main.html
app/client/main.js // here you import import '../imports/startup/client/' and import '../imports/ui'
“In the example, useraccounts-config.js is recommended under import/startup/client” - this is right and you should have it imported in app/client/main.js
" Account.onCreateUser()
could only work in the import/startup/server folder" - that is right. You can put it under app/server
directly or have it put in app/imports/startup/server
but need to make sure this folder has an index.js that imports each file in this folder and it is being imported by main.js under app/server
Logic: you build all your login/signup/renew password etc in the client side calling methods which run server side. When a user is being created, a server side routine (onCreateUser.js)will further process your user.
client
- all your logic for what the user experiences. If you have routes like example.com/singin, example.com/signup, in those templates you build the entire login logic.
server
- listen to when a user is being created and do further processing (e.g. get the image from FB profile and save it to a CDN, retrieve the CDN url of the image and save it under user’s profile avatar)
For testing, you could do so:
- Put onCreateUser.js under app/server directly
- Write this simple code:
import { Accounts } from 'meteor/accounts-base'
Accounts.onCreateUser((options, user) => {
console.log({ options, user })
if (user.emails?.[0]) {
user.hasEmail = true
}
return user
})
Check your server console when creating a new user.
“sign up public routes (in routes.js).” - routes should stay unders app/imports/startup/client
. In client startup you have things that should be running after the JS bundle is processed, before the DOM is being constructed.