我正在尝试根据角色呈现管理视图。 问题是,当我通过身份验证时,渲染不会改变。
我一直看到: 登入 你不是管理员
import React, { Component } from 'react';
import EasyTransition from 'react-easy-transition';
import {Meteor} from 'meteor/meteor';
import { createContainer } from 'meteor/react-meteor-data';
import { Roles } from 'meteor/alanning:roles';
import AccountsUI from './accounts_ui/login_buttons';
import Sidebar from './sidebar';
class AdminApp extends Component {
render() {
if (this.props.isAdminUser) {
return (
<div>
<EasyTransition path={location.pathname}
initialStyle={{opacity: 0}}
transition="opacity 0.3s ease-in"
finalStyle={{opacity: 1}}>
<Sidebar/>
{this.props.children}
</EasyTransition>
</div>
)
}
if (!this.props.isAdminUser) {
return (
<div className="wrapper">
<AccountsUI/>
<p>You are not admin</p>
</div>
)
}
}
};
export default createContainer(() => {
if (Roles.userIsInRole(Meteor.userId(), ['superadmin'], 'backend')) {
return {isAdminUser: true}
}
return {isAdminUser: false}
}, AdminApp)
我已登录但渲染没有改变,我在这里缺少什么?