tramway-api 2.0 → 2.0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d0caeaa1462195c9c7d270d716a7970ce658f6ffbfaf139662bc3c0e382630c
4
- data.tar.gz: 7c7cef68dfa06f0cb0dcdfd530e28c0a41b42515bb175a9978946ed13c6b7600
3
+ metadata.gz: c5ab385b1f17e7f65727c6601d470043e3c76c393409f38b914d79c05e6df524
4
+ data.tar.gz: d82903e94875d6a00eb3c885ccf0b28b11c62e1183abec7e5ff1d646b1b8224d
5
5
  SHA512:
6
- metadata.gz: f5659a1cad529417c3bdccc5766167690654008e0c2e903e6efb638277c4d7fe161ec9bfcb18a91088c3ba58a5204a3f13efbfd5fa6fef4a7746e03e60f6a872
7
- data.tar.gz: 738e22ab29825ec1ebe351c5a3e5c64b2e92a87fee4e84e8285c16b31a664faefc0ec75a67e65c9c5c8705df2b59d24106c4bd26454abd68dedee5b0b9ec337f
6
+ metadata.gz: 226e85b0c6f7ce0f46ab03f0ae1be2bad0ef7ac645a45498473520b86d4e36ab05ef56d02c3fa3a0f2dc57e50d1a99ca4b6fe934072df8938ee55ebd33875688
7
+ data.tar.gz: e14d07574e5d6cc8603707ec5b95f46f2b9ddcff0f7be5d5ee127db0e72daefb02cbe9de1f1d0bf7410051b9aec6c249e6e0f7f3f8b92a390b3a02d9241992cc
@@ -16,7 +16,7 @@ module Tramway
16
16
  end
17
17
 
18
18
  def authenticate
19
- return if current_user || params[:user_based_model].in?(Tramway::Api.user_based_models)
19
+ return if current_tramway_user || params[:user_based_model].in?(Tramway::Api.user_based_models)
20
20
 
21
21
  unauthorized
22
22
  end
@@ -54,7 +54,7 @@ module Tramway
54
54
  params[:auth]&.permit(:login, :password)
55
55
  end
56
56
 
57
- def current_user
57
+ def current_tramway_user
58
58
  Tramway::Api.user_based_models.map do |user_based_model|
59
59
  send("current_#{user_based_model.constantize.name.underscore}") unless user_based_model == User
60
60
  end.compact.first
@@ -44,7 +44,7 @@ module Tramway
44
44
 
45
45
  def check_available_model_class
46
46
  unless model_class
47
- head(:unauthorized) && return unless current_user
47
+ head(:unauthorized) && return unless current_tramway_user
48
48
 
49
49
  head(:unprocessable_entity) && return
50
50
  end
@@ -53,7 +53,7 @@ module Tramway
53
53
  def check_available_model_action_for_record
54
54
  action_is_available = check_action
55
55
  action_is_available.tap do
56
- if action_is_available.is_a?(Proc) && !action_is_available.call(record, current_user)
56
+ if action_is_available.is_a?(Proc) && !action_is_available.call(record, current_tramway_user)
57
57
  head(:unprocessable_entity) && return
58
58
  end
59
59
  end
@@ -63,7 +63,7 @@ module Tramway
63
63
  action_is_available = check_action
64
64
  return records if action_is_available == true
65
65
 
66
- action_is_available.call records, current_user if action_is_available.is_a?(Proc)
66
+ action_is_available.call records, current_tramway_user if action_is_available.is_a?(Proc)
67
67
  end
68
68
 
69
69
  def check_action
@@ -73,7 +73,7 @@ module Tramway
73
73
  project: (@application_engine || application_name),
74
74
  role: role,
75
75
  model_name: params[:model],
76
- current_user: current_user
76
+ current_tramway_user: current_tramway_user
77
77
  )
78
78
  end.compact.uniq - [false]
79
79
 
@@ -94,17 +94,17 @@ module Tramway
94
94
  project: (@application_engine || application_name),
95
95
  model_name: params[:model]
96
96
  )
97
- head(:unauthorized) && return if !current_user && !action_is_open
97
+ head(:unauthorized) && return if !current_tramway_user && !action_is_open
98
98
  end
99
99
 
100
- def available_models_for_current_user
100
+ def available_models_for_current_tramway_user
101
101
  checking_roles.reduce([]) do |models, role|
102
102
  models += ::Tramway::Api.available_models(role: role).map(&:to_s)
103
103
  end
104
104
  end
105
105
 
106
106
  def checking_roles
107
- [:open, current_user&.role].compact
107
+ [:open, current_tramway_user&.role].compact
108
108
  end
109
109
 
110
110
  protected
@@ -26,7 +26,7 @@ class Tramway::Api::V1::UsersController < ::Tramway::Api::V1::ApplicationControl
26
26
  end
27
27
 
28
28
  def show
29
- render json: current_user, status: :ok
29
+ render json: current_tramway_user, status: :ok
30
30
  end
31
31
 
32
32
  private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Api
5
- VERSION = '2.0'
5
+ VERSION = '2.0.0.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-api
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.0'
4
+ version: 2.0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-25 00:00:00.000000000 Z
11
+ date: 2022-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  requirements: []
119
- rubygems_version: 3.0.3.1
119
+ rubygems_version: 3.1.6
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Engine for api