tramway-api 1.3.1 → 1.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 875752ec80bea3a12cdac3f2a3424f777fc0bcf4a94b6c28a5f1c4f98e5a6e34
|
4
|
+
data.tar.gz: ce5f8b2cb550ad0d1a5495ae622152119dc4253dd045fa348fa6921a88751691
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b629b1c487b02b054885db26d4e49b97ed652cda40cb4d53e11d25cca170d8d0d876619b13df307cb0a19290d9f7447196dc4f24b5c7962edfad26092a194ff
|
7
|
+
data.tar.gz: 37241c50fc18e27b16fb2c4a2c7eb10ec611b163a046c92cca128a95ca9127950e0e739ddc5ff468890cc40da59bca2d569c04b1d7a8cfac7c24d3baba6fcc86
|
@@ -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
|
-
|
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