2009-08-02 19:41:09 +02:00
|
|
|
class InvitesController < ApplicationController
|
2019-10-28 21:11:35 +01:00
|
|
|
before_action :authenticate_membership_or_admin_for_invites
|
|
|
|
before_action -> { require_config_disabled :disable_invite }
|
|
|
|
|
2009-08-02 19:41:09 +02:00
|
|
|
def new
|
|
|
|
@invite = Invite.new(:user => @current_user, :group => @group)
|
|
|
|
end
|
2021-03-01 15:27:26 +01:00
|
|
|
|
2009-08-02 19:41:09 +02:00
|
|
|
def create
|
2013-12-22 14:20:25 +01:00
|
|
|
authenticate_membership_or_admin params[:invite][:group_id]
|
2009-08-02 19:41:09 +02:00
|
|
|
@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
|
2012-10-15 21:19:17 +02:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
2013-12-22 13:58:49 +01:00
|
|
|
redirect_to root_path, notice: I18n.t('invites.success')
|
2012-10-15 21:19:17 +02:00
|
|
|
end
|
|
|
|
format.js { render layout: false }
|
|
|
|
end
|
|
|
|
|
2012-08-06 12:00:40 +02:00
|
|
|
else
|
|
|
|
render action: :new
|
2009-08-02 19:41:09 +02:00
|
|
|
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
|
2009-08-02 19:41:09 +02:00
|
|
|
end
|