diff --git a/app/controllers/api/v1/posts_controller.rb b/app/controllers/api/v1/posts_controller.rb index ed8872e..2b414b0 100644 --- a/app/controllers/api/v1/posts_controller.rb +++ b/app/controllers/api/v1/posts_controller.rb @@ -1,5 +1,6 @@ class Api::V1::PostsController < ApplicationController + skip_before_action :verify_authenticity_token before_action :authenticate_user_from_token before_action :permit_params, only: [:create] @@ -10,8 +11,8 @@ class Api::V1::PostsController < ApplicationController def create post = get_post - share_instance = @current_user.share_instances.create sharable: post, description: params[:description] - render json: share_instance.to_json(include: :sharable) + @share_instance = @current_user.share_instances.create sharable: post, description: params[:description] + render json: @share_instance.to_json(include: :sharable) end def show diff --git a/app/controllers/api/v1/registrations_controller.rb b/app/controllers/api/v1/registrations_controller.rb index c008a91..7bb3bfc 100644 --- a/app/controllers/api/v1/registrations_controller.rb +++ b/app/controllers/api/v1/registrations_controller.rb @@ -1,5 +1,5 @@ class Api::V1::RegistrationsController < ApplicationController - + skip_before_action :verify_authenticity_token respond_to :json def create diff --git a/app/controllers/api/v1/sessions_controller.rb b/app/controllers/api/v1/sessions_controller.rb index a5678f6..4f5d45c 100644 --- a/app/controllers/api/v1/sessions_controller.rb +++ b/app/controllers/api/v1/sessions_controller.rb @@ -1,5 +1,5 @@ class Api::V1::SessionsController < Devise::SessionsController - + skip_before_action :verify_authenticity_token def create warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#failure") render json: user_json diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a729966..0111fb7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. # protect_from_forgery with: :exception - protect_from_forgery with: :null_session + protect_from_forgery with: :exception before_action :current_user!