checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: 61be23f5286206cfab7b53a7d5d9b5675ac90323034b7382220f3f6e7dfb97cf
4
- data.tar.gz: d144a30fa41a7d22394710c137f84c2eb1066ed7d0bc2123cd92bb30eb918084
3
+ metadata.gz: 875752ec80bea3a12cdac3f2a3424f777fc0bcf4a94b6c28a5f1c4f98e5a6e34
4
+ data.tar.gz: ce5f8b2cb550ad0d1a5495ae622152119dc4253dd045fa348fa6921a88751691
5
5
SHA512:
6
- metadata.gz: 96071be124def6faf1c5820d620b5df917c78754b773a4c1bf6a127fe7b0518d88d3752d44bde2cdaa59c3478e8fedcd95a2eed12b02ceeca97535119f11aec9
7
- data.tar.gz: b189159882e907f4a308134def79b8f2d370b4d74dec513639c5cad2c9e644a8983e817c539a37fa25a3b3c905b222d03140a4bbabb2b48d915def5a6ab30116
6
+ metadata.gz: 8b629b1c487b02b054885db26d4e49b97ed652cda40cb4d53e11d25cca170d8d0d876619b13df307cb0a19290d9f7447196dc4f24b5c7962edfad26092a194ff
7
+ data.tar.gz: 37241c50fc18e27b16fb2c4a2c7eb10ec611b163a046c92cca128a95ca9127950e0e739ddc5ff468890cc40da59bca2d569c04b1d7a8cfac7c24d3baba6fcc86
data/app/controllers/tramway/api/v1/records_controller.rb CHANGED
@@ -2,6 +2,7 @@ module Tramway::Api::V1
2
2
class RecordsController < ::Tramway::Api::V1::ApplicationController
3
3
before_action :check_available_model_class
4
4
before_action :check_available_model_action
5
+ before_action :authenticate_user_if_needed
5
6
6
7
def index
7
8
records = model_class.active.order(id: :desc).send params[:scope] || :all
@@ -54,7 +55,14 @@ module Tramway::Api::V1
54
55
end
55
56
56
57
def check_available_model_action
57
- head :unprocessable_entity and return unless action_name.in? Tramway::Api.available_models[model_class.to_s].map(&:to_s)
58
+ actions = Tramway::Api.available_models[model_class.to_s][:open]&.map(&:to_s) || [] + Tramway::Api.available_models[model_class.to_s][:closed]&.map(&:to_s) || []
59
+ head :unprocessable_entity and return unless action_name.in? actions
60
+ end
61
+
62
+ def authenticate_user_if_needed
63
+ if action_name.in? Tramway::Api::available_models[model_class.to_s][:closed]&.map(&:to_s) || []
64
+ authenticate_user
65
+ end
58
66
end
59
67
60
68
def model_class
data/lib/tramway/api/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
module Tramway
2
2
module Api
3
- VERSION = '1.3.1'
3
+ VERSION = '1.4'
4
4
end
5
5
end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
--- !ruby/object:Gem::Specification
2
2
name: tramway-api
3
3
version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: '1.4'
5
5
platform: ruby
6
6
authors:
7
7
- Pavel Kalashnikov