about summary refs log tree commit diff
path: root/app/controllers/invites_controller.rb
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-05-11 18:12:42 +0200
committerThibaut Girka <thib@sitedethib.com>2018-05-11 18:12:42 +0200
commit45fce0e496727cd1579c630c22592638341f78c6 (patch)
treeff72ae5b3482e4df7885e1e5a38c982529fd11c4 /app/controllers/invites_controller.rb
parent34142ab29c33104793afe3199f102d84b83b9b57 (diff)
parent352bae8c3ef2aca41de4aacb85d5e036a1d2bace (diff)
Merge branch 'master' into glitch-soc/merge
Conflicts:
	app/controllers/invites_controller.rb
	app/serializers/initial_state_serializer.rb
	config/locales/ko.yml
Diffstat (limited to 'app/controllers/invites_controller.rb')
-rw-r--r--app/controllers/invites_controller.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb
index 189e4072e..2e9f73bb8 100644
--- a/app/controllers/invites_controller.rb
+++ b/app/controllers/invites_controller.rb
@@ -9,9 +9,9 @@ class InvitesController < ApplicationController
   before_action :set_pack
 
   def index
-    authorize :invite, :create?
+    authorize :invite, :index?
 
-    @invites = Invite.where(user: current_user)
+    @invites = invites
     @invite  = Invite.new(expires_in: 1.day.to_i)
   end
 
@@ -24,13 +24,13 @@ class InvitesController < ApplicationController
     if @invite.save
       redirect_to invites_path
     else
-      @invites = Invite.where(user: current_user)
+      @invites = invites
       render :index
     end
   end
 
   def destroy
-    @invite = Invite.where(user: current_user).find(params[:id])
+    @invite = invites.find(params[:id])
     authorize @invite, :destroy?
     @invite.expire!
     redirect_to invites_path
@@ -42,6 +42,10 @@ class InvitesController < ApplicationController
     use_pack 'settings'
   end
 
+  def invites
+    Invite.where(user: current_user)
+  end
+
   def resource_params
     params.require(:invite).permit(:max_uses, :expires_in)
   end