Search code examples
meteoriron-router

Meteor routing filter not working


i am trying to create an admin interface for my meteor project and for this i created a custom accounts register form which says

Accounts.createUser({
email: userEmail,
password: userPassword,
admin: true
})

and in my router.js code i have this

Router.route('/admin', {name: 'admin'})

var requireAdminLogin = function(){
if(!Meteor.user({admin: true})){
this.render('accessDenied')
}else{
this.next();
}
}

Router.onBeforeAction(requireAdminLogin, {only: 'admin'})

the problem is even when i change my register code to say that the new user signing up is not admin, i can still get to my admin page. Can anyone help? thank you


Solution

  • A package called houston:admin did exactly what I wanted to do.