diff --git a/app/controllers/concerns/followable_controller.rb b/app/controllers/concerns/followable_controller.rb index d4d1cf569c518cd6fa3caf4e6aaf47478e6e12e9..40cd9139c58200a605c9275eebad11669c096657 100644 --- a/app/controllers/concerns/followable_controller.rb +++ b/app/controllers/concerns/followable_controller.rb @@ -4,7 +4,7 @@ module FollowableController extend ActiveSupport::Concern included do - before_action :authenticate_user!, only: [:follow, :unfollow] + before_action :authenticate_user!, only: [:follow, :unfollow, :follow_toggle] end # POST /v1/users/1/follow diff --git a/app/controllers/v1/collections_controller.rb b/app/controllers/v1/collections_controller.rb index f98194f415a493d02a97252fbfae90702ca218c2..de2f898e974414262eba88d13e6842292f5a851a 100644 --- a/app/controllers/v1/collections_controller.rb +++ b/app/controllers/v1/collections_controller.rb @@ -9,10 +9,10 @@ class V1::CollectionsController < ApplicationController include ::SubjectableController include ::StageableController - before_action :authenticate_user!, only: [:create, :update, :destroy, :tagging, :untagging] - before_action :set_collection, only: [:show, :update, :destroy, :add_object, :delete_object, :subjecting, :unsubjecting, :add_stages, :remove_stages] + before_action :authenticate_user!, only: [:create, :update, :destroy, :tagging, :untagging, :follow, :unfollow, :follow_toggle] + before_action :set_collection, only: [:show, :update, :destroy, :add_object, :delete_object, :subjecting, :unsubjecting, :add_stages, :remove_stages, :follow, :unfollow, :follow_toggle] before_action :set_new_collection, only: :index - before_action :authorize!, except: [:create, :tagging, :untagging, :follow, :unfollow, :download] + before_action :authorize!, except: [:create, :tagging, :untagging, :download] # GET /v1/collections # GET /v1/collections.json diff --git a/app/policies/followable_policy.rb b/app/policies/followable_policy.rb index 17aba92708f7ba0ea0ddd702d95a22cb1fc1c3e6..c3b5870e6dc8d28f74f98112e4263f2bf8f59b9e 100644 --- a/app/policies/followable_policy.rb +++ b/app/policies/followable_policy.rb @@ -7,4 +7,8 @@ module FollowablePolicy def unfollow? record if user_exists? end + + def follow_toggle? + record if user_exists? + end end