foodsoft/app/controllers/invites_controller.rb

34 lines
837 B
Ruby
Raw Normal View History

class InvitesController < ApplicationController
before_action :authenticate_membership_or_admin_for_invites
before_action -> { require_config_disabled :disable_invite }
def new
@invite = Invite.new(:user => @current_user, :group => @group)
end
def create
2013-12-22 14:20:25 +01:00
authenticate_membership_or_admin params[:invite][:group_id]
@invite = Invite.new(params[:invite])
2012-08-06 12:00:40 +02:00
if @invite.save
2015-01-13 18:02:30 +01:00
Mailer.invite(@invite).deliver_now
respond_to do |format|
format.html do
redirect_to root_path, notice: I18n.t('invites.success')
end
format.js { render layout: false }
end
2012-08-06 12:00:40 +02:00
else
render action: :new
end
end
2013-12-22 14:20:25 +01:00
protected
def authenticate_membership_or_admin_for_invites
authenticate_membership_or_admin((params[:invite][:group_id] rescue params[:id]))
end
end