2016-03-18 10:50:40 +09:00
|
|
|
import React, { PropTypes, Component } from 'react';
|
|
|
|
|
2016-04-05 18:05:41 +09:00
|
|
|
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;
|
2016-04-05 18:05:41 +09:00
|
|
|
|
|
|
|
if (!currentUser){
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<h3>Please Log In</h3>
|
2016-04-19 16:14:41 +09:00
|
|
|
<UsersAccountForm/>
|
2016-04-05 18:05:41 +09:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
} else if (Users.can.post(currentUser)) {
|
2016-03-17 18:08:03 +09:00
|
|
|
return children;
|
|
|
|
} else {
|
|
|
|
return <p>Sorry, you do not have permissions to post at this time</p>;
|
2016-02-22 13:23:46 +09:00
|
|
|
}
|
2016-03-17 18:08:03 +09:00
|
|
|
};
|
2016-02-22 13:23:46 +09:00
|
|
|
|
2016-04-05 18:05:41 +09:00
|
|
|
CanCreatePost.contextTypes = {
|
|
|
|
currentUser: React.PropTypes.object
|
|
|
|
};
|
2016-02-22 13:23:46 +09:00
|
|
|
|
|
|
|
module.exports = CanCreatePost;
|