Creating routes for the admin
Now that we have an admin user, we can add the routes, which lead to the editPost
template. Though in theory the editPost
template is available to every client, it doesn't create any risk, as the allow and deny rules are the real security layer, which we will take a look at in the next chapter.
To add the route to create posts, let's open up our my-meteor-blog/routes.js
file and add the following route to the Router.map()
function:
this.route('Create Post', { path: '/create-post', template: 'editPost' });
This will simply show the editPost
template as soon as we click on the Create new post link on our home page, as shown in the following screenshot:
We see that the form is empty because we did not set any data context to the template, and therefore the {{title}}
, {{description}}
, and {{text}}
placeholders in the template displayed nothing.
To make the edit post route work, we need to add subscriptions similar to those we did for the Post
route itself. To...