Add autofollow option to invites (#7805)
* Add autofollow option to invites * Trigger CodeClimate rebuild
This commit is contained in:
parent
33dd9bf36d
commit
ca85658975
12 changed files with 108 additions and 18 deletions
|
@ -3,6 +3,7 @@
|
|||
class Auth::RegistrationsController < Devise::RegistrationsController
|
||||
layout :determine_layout
|
||||
|
||||
before_action :set_invite, only: [:new, :create]
|
||||
before_action :check_enabled_registrations, only: [:new, :create]
|
||||
before_action :configure_sign_up_params, only: [:create]
|
||||
before_action :set_sessions, only: [:edit, :update]
|
||||
|
@ -51,7 +52,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
|||
end
|
||||
|
||||
def allowed_registrations?
|
||||
Setting.open_registrations || (invite_code.present? && Invite.find_by(code: invite_code)&.valid_for_use?)
|
||||
Setting.open_registrations || @invite&.valid_for_use?
|
||||
end
|
||||
|
||||
def invite_code
|
||||
|
@ -68,6 +69,10 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
|||
@instance_presenter = InstancePresenter.new
|
||||
end
|
||||
|
||||
def set_invite
|
||||
@invite = invite_code.present? ? Invite.find_by(code: invite_code) : nil
|
||||
end
|
||||
|
||||
def determine_layout
|
||||
%w(edit update).include?(action_name) ? 'admin' : 'auth'
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ class InvitesController < ApplicationController
|
|||
authorize :invite, :create?
|
||||
|
||||
@invites = invites
|
||||
@invite = Invite.new(expires_in: 1.day.to_i)
|
||||
@invite = Invite.new
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -42,6 +42,6 @@ class InvitesController < ApplicationController
|
|||
end
|
||||
|
||||
def resource_params
|
||||
params.require(:invite).permit(:max_uses, :expires_in)
|
||||
params.require(:invite).permit(:max_uses, :expires_in, :autofollow)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue