tramway-api 1.7.0.3 → 1.7.0.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: 94170f0f2f5bf4138fc21cc86290ac51092fd6580d98ec9ee01e143e3a846f8e
4
- data.tar.gz: c610745ab3cd6eb82116c9720d846ac17a7bf7bef5a5f496f850cbd6bad8f793
3
+ metadata.gz: 56da4809e88d47a601a85acdeed9104c1ec4114c33a1c6cbc2c3a86b41a49003
4
+ data.tar.gz: 5c68a2cb731c77780b7ccdf399b66b792dd11626447eb9b676311ac5a839d840
5
5
  SHA512:
6
- metadata.gz: 214f6b56a98a0a4fcbc02431178c77cbf0e0d2eafb020e2183a8266398266fc72c2e193327616f36b5293a1c386a2286ad3fe018e478ebbd57c00a24d34745ee
7
- data.tar.gz: 5b3f18221ede26fb67bacb212ecd93794b379fd69d40723eb5f771b686b967f9bb5d1a83a191ee7fc5c2de44adc3a951f57b8a5abf513fe69cfc0221a1b52753
6
+ metadata.gz: a7eb92d306828573f93795a3fbbebd5df72a5a63af74144d19aed2658d1245fad3d9579582d9611765884357dca7d8c3804509e2e836d10a30cf9dab3e5a4553
7
+ data.tar.gz: e23a71a3d8a71b9ef5159ac2361912a186a0f7b522b83a8ca0951a84240485f9a31213f73f82fe30d207b168ffaf22786bb7fd46e3baa173a8b707c1474af6bc
data/README.md CHANGED
@@ -70,12 +70,22 @@ Then generate User (you use another name, it's just an example) model
70
70
  rails g model user email:text password_digest:text username:text state:text uid:text
71
71
  ```
72
72
 
73
- Add generating uid by default
73
+ Enable extension in your database:
74
74
 
75
- *db/migrate/create_users_*.rb
75
+ *db/migrate/enable_extension.rb*
76
+ ```
77
+ def change
78
+ enable_extension 'uuid-ossp'
79
+ end
80
+ ```
81
+
82
+
83
+ Add generating uuid by default to every model, that is accessible by API
84
+
85
+ *db/migrate/add_uuid_to_some_model.rb*
76
86
 
77
87
  ```ruby
78
- t.uuid :uid, default: 'uuid_generate_v4()'
88
+ t.uuid :uuid, default: 'uuid_generate_v4()'
79
89
  ```
80
90
 
81
91
  *app/models/user.rb*
@@ -85,7 +95,7 @@ class User < Tramway::Core::ApplicationRecord
85
95
  has_secure_password
86
96
 
87
97
  def self.from_token_payload(payload)
88
- find_by uid: payload['sub']
98
+ find_by uuid: payload['sub']
89
99
  end
90
100
  end
91
101
  ```
@@ -227,7 +237,7 @@ RSpec.describe 'Post generate token', type: :feature do
227
237
  post '/api/v1/user_token', params: { auth: { login: user.email, password: '123456789' } }
228
238
 
229
239
  expect(json_response[:auth_token].present?).to be_truthy
230
- expect(json_response[:user]).to include_json({ email: user.email, uid: user.uid })
240
+ expect(json_response[:user]).to include_json({ email: user.email, uuid: user.uuid })
231
241
  end
232
242
 
233
243
  end
@@ -18,12 +18,14 @@ module Tramway
18
18
  end
19
19
 
20
20
  def user_based_models
21
+ @@auth_config ||= []
21
22
  @@auth_config.map do |conf|
22
23
  conf[:user_model]
23
24
  end
24
25
  end
25
26
 
26
27
  def auth_attributes
28
+ @@auth_config ||= []
27
29
  @@auth_config.reduce({}) do |hash, conf|
28
30
  hash.merge! conf[:user_model] => conf[:auth_attributes]
29
31
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Api
5
- VERSION = '1.7.0.3'
5
+ VERSION = '1.7.0.4'
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: 1.7.0.3
4
+ version: 1.7.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-21 00:00:00.000000000 Z
11
+ date: 2020-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers