about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-06-15 20:51:39 +0200
committerThibaut Girka <thib@sitedethib.com>2018-06-15 20:51:39 +0200
commitdb200226b805db324a8efdfb951d7725eac3f9da (patch)
treea7d8298fc65bbd81e2f843048240de6e4fceffcf /app/controllers
parentafceef74c2377192f100b9307068895ec0ec7d45 (diff)
parent0df91c7b1e05952ebbfc552915e995d55af0a403 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
	app/javascript/mastodon/initial_state.js
	db/schema.rb

Upstream added a new field to initial_state.
Not too sure about what happened with db/schema.rb though…
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/auth/registrations_controller.rb7
-rw-r--r--app/controllers/invites_controller.rb4
2 files changed, 8 insertions, 3 deletions
diff --git a/app/controllers/auth/registrations_controller.rb b/app/controllers/auth/registrations_controller.rb
index 9b3ea4f27..c5f43d583 100644
--- a/app/controllers/auth/registrations_controller.rb
+++ b/app/controllers/auth/registrations_controller.rb
@@ -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_pack
@@ -52,7 +53,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
@@ -73,6 +74,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
diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb
index 70818610c..1053e9c42 100644
--- a/app/controllers/invites_controller.rb
+++ b/app/controllers/invites_controller.rb
@@ -12,7 +12,7 @@ class InvitesController < ApplicationController
     authorize :invite, :create?
 
     @invites = invites
-    @invite  = Invite.new(expires_in: 1.day.to_i)
+    @invite  = Invite.new
   end
 
   def create
@@ -47,6 +47,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