進出口使用FlowRouter
與FlowTemplate
和both/router/router.js
我檢查是用戶角色admin
:Roles.userIsInRole返回FALSE - 流星
....
action: function() {
if(Roles.userIsInRole(Meteor.userId(), 'admin')){
FlowLayout.render('layout', {
sidebar: 'sidebar', main:'admin', cart:'cart'
})
} else {
FlowLayout.render('layout', {
sidebar: 'sidebar', main:'unauthorised', cart:'cart'
})
}
console.log(Meteor.userId());
}
....
,並返回FALSE
,但是當我使用它在Web控制檯是TRUE
。此行console.log(Meteor.userId());
輸出正確的userID
,當我登錄時,如果我在WEB控制檯Roles.userIsInRole(Meteor.userId(), 'admin')
中執行此操作,則它是TRUE
。如果我這樣做Meteor.user().roles
,結果是['admin']
如果我在模板檢查是用戶角色:
{{#if isInRole 'admin' }}
ADMIN
{{/if}}
這是TRUE
,但在router.js
回報FALSE
。
如何解決?