Merge branch 'feature/restrict-group-creation-to-pros' into 'develop'

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

See merge request gab/social/gab-social!29
This commit is contained in:
Rob Colbert 2019-08-01 16:55:08 +00:00
commit bc20f0e172
3 changed files with 10 additions and 2 deletions

View File

@ -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

View File

@ -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">

View File

@ -5,6 +5,10 @@ class GroupPolicy < ApplicationPolicy
true
end
def create?
admin? or current_account.is_pro
end
def update?
if admin?
true