Vulcan/packages/nova-base-components/lib/permissions/CanCreatePost.jsx

30 lines
678 B
React
Raw Normal View History

import React, { PropTypes, Component } from 'react';
const CanCreatePost = (props, context) => {
const currentUser = context.currentUser;
const children = props.children;
2016-04-19 16:14:41 +09:00
const UsersAccountForm = Telescope.components.UsersAccountForm;
if (!currentUser){
return (
<div>
<h3>Please Log In</h3>
2016-04-19 16:14:41 +09:00
<UsersAccountForm/>
</div>
)
} else if (Users.can.post(currentUser)) {
return children;
} else {
return <p>Sorry, you do not have permissions to post at this time</p>;
}
};
CanCreatePost.contextTypes = {
currentUser: React.PropTypes.object
};
CanCreatePost.displayName = "CanCreatePost";
module.exports = CanCreatePost;