[英]Set router for different roles Meteor Js
如何設置路由器的不同角色。 這是我的代碼。 有人可以幫我嗎。
if (Roles.userIsInRole(['admin'])) {
Router.go('/addItem');
}
else {
Roles.userIsInRole(['admin-category'])
Router.go('/AddCategory');
}
假設您使用iron:router
,則可以通過幾種方法來實現。 您可以在路由上設置onBeforeAction
鈎子,該路由將通過Router.go
重定向到適當的路由/模板, 在doc上檢查鈎子 。 您還應該能夠根據情況呈現其他模板:
if (Roles.userIsInRole(Meteor.userId(), ['admin'])) {
this.render('addItem');
} else if Roles.userIsInRole(Meteor.userId(), ['admin-category']) {
this.render('addCategory');
} else {
this.render('defaultRoute');
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.