Skip to content

Commit

Permalink
enforce admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Connoropolous committed Apr 19, 2016
1 parent 6a2c126 commit a97fa3b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,23 @@ def update
api :POST, '/groups/:id/add_card', 'Add a credit card that pays for the group'
def add_card
group = Group.find(params[:id])
group.add_card(params[:stripeEmail], params[:stripeToken])
render status: 200, nothing: true
if current_user.is_admin_for?(group)
group.add_card(params[:stripeEmail], params[:stripeToken])
render status: 200, nothing: true
else
render status: 403, nothing: true
end
end

api :POST, '/groups/:id/extend_trial', 'Extend the group trial by 30 days'
def extend_trial
group = Group.find(params[:id])
group.extend_trial()
render status: 200, nothing: true
if current_user.is_admin_for?(group)
group.extend_trial()
render status: 200, nothing: true
else
render status: 403, nothing: true
end
end

private
Expand Down

0 comments on commit a97fa3b

Please sign in to comment.