Commit 3fa8eb1b authored by 2458773093's avatar 2458773093

Added restriction to group policy. Create link hidden for non-pro.

parent 8c837a0c
......@@ -33,6 +33,8 @@ class Api::V1::GroupsController < Api::BaseController
end
def create
authorize :group, :create?
@group = Group.create!(group_params.merge(account: current_account))
render json: @group, serializer: REST::GroupSerializer
end
......
......@@ -9,6 +9,7 @@ import { Link } from 'react-router-dom';
import classNames from 'classnames';
import GroupCard from './card';
import GroupCreate from '../create';
import { me } from 'gabsocial/initial_state';
const messages = defineMessages({
heading: { id: 'column.groups', defaultMessage: 'Groups' },
......@@ -20,6 +21,7 @@ const messages = defineMessages({
const mapStateToProps = (state, { activeTab }) => ({
groupIds: state.getIn(['group_lists', activeTab]),
account: state.getIn(['accounts', me]),
});
export default @connect(mapStateToProps)
......@@ -46,11 +48,11 @@ class Groups extends ImmutablePureComponent {
}
renderHeader() {
const { intl, activeTab } = this.props;
const { intl, activeTab, account } = this.props;
return (
<div className="group-column-header">
<div className="group-column-header__cta"><Link to="/groups/create" className="button standard-small">{intl.formatMessage(messages.create)}</Link></div>
{account && account.get('is_pro') && <div className="group-column-header__cta"><Link to="/groups/create" className="button standard-small">{intl.formatMessage(messages.create)}</Link></div>}
<div className="group-column-header__title">{intl.formatMessage(messages.heading)}</div>
<div className="column-header__wrapper">
......
......@@ -5,6 +5,10 @@ class GroupPolicy < ApplicationPolicy
true
end
def create?
admin? or current_account.is_pro
end
def update?
if admin?
true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment