as an iOS developer in the first place, I am very new to webdev. I look at Meteor and ask some questions regarding routing - my apologies if they are very light.
I use the Meteor Router package to create routes, but I would like some pages to be accessible only to the admin user.
Meteor.Router.add({ '/' : 'home', '/admin' : 'admin' });
So, I have a simple route setup as above, but I'm not sure how to restrict access to the / admin route.
Is it as simple as something like this? What would be a good way to limit the route to the / admin page and show a warning, or perhaps even redirect them back to the / page?
Thanks!
client.html
<head> <title>My App</title> </head> <body> {{renderPage}} </body> <template name="home"> {{greeting}} </template> <template name="admin"> {{greeting}} </template>
client.js
Template.admin.greeting = function () { var currentUser = Meteor.user(); if (null !== currentUser && 'admin' === currentUser.username) { return "Hello Admin!"; } else{ return "Sorry, only admins can see this page"; } };
meteor
kurisukun
source share