tramway-api 1.0.3 → 1.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 +4 -4
- data/app/controllers/tramway/api/application_controller.rb +10 -2
- data/lib/tramway/api/version.rb +1 -1
- data/lib/tramway/api.rb +11 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dd077883596f2b69e87b35d326323415bf8c5184636caf46ab18d8377d01494
|
4
|
+
data.tar.gz: 7618b6d6fc2b0b45282747a5042fdf2976dcb2e66896e301ac6fde8d43c41331
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e93025a3e5f55e928a60879a4552440f5f8eb198c8af379419d776d8d1dfe735eaf7a87d4cda09bb3461633f581e4d32828aecf33b80b43d70b24a8cb0b7857
|
7
|
+
data.tar.gz: 974204ec735f413a47e1469443d1f2638346dea60792be83f438868de0d4c411b10a99f19fedaabfa0a9176519017c78c9546099d6701d0911ee6eebfca47a83
|
@@ -34,12 +34,20 @@ module Tramway
|
|
34
34
|
if Tramway::Api.user_based_model.respond_to? :from_token_request
|
35
35
|
Tramway::Api.user_based_model.active.from_token_request request
|
36
36
|
else
|
37
|
-
params[:auth] &&
|
37
|
+
params[:auth] && find_user_by_auth_attributes
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
def find_user_by_auth_attributes
|
42
|
+
Tramway::Api.auth_attributes.each do |attribute|
|
43
|
+
object = Tramway::Api.user_based_model.active.where.not(attribute => nil).find_by(attribute => auth_params[:login])
|
44
|
+
return object if object
|
45
|
+
end
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
|
41
49
|
def auth_params
|
42
|
-
params[:auth]&.permit
|
50
|
+
params[:auth]&.permit(:login, :password)
|
43
51
|
end
|
44
52
|
end
|
45
53
|
end
|
data/lib/tramway/api/version.rb
CHANGED
data/lib/tramway/api.rb
CHANGED
@@ -3,12 +3,20 @@ require 'tramway/api/engine'
|
|
3
3
|
module Tramway
|
4
4
|
module Api
|
5
5
|
class << self
|
6
|
+
def auth_config
|
7
|
+
@@auth_config ||= { user_model: ::Tramway::User::User, auth_attributes: :email }
|
8
|
+
end
|
9
|
+
|
10
|
+
def auth_config=(**params)
|
11
|
+
@@auth_config = params
|
12
|
+
end
|
13
|
+
|
6
14
|
def user_based_model
|
7
|
-
@@
|
15
|
+
@@auth_config[:user_model]
|
8
16
|
end
|
9
17
|
|
10
|
-
def
|
11
|
-
@@
|
18
|
+
def auth_attributes
|
19
|
+
@@auth_config[:auth_attributes]
|
12
20
|
end
|
13
21
|
|
14
22
|
def set_available_models(**models)
|
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.
|
4
|
+
version: '1.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: 2019-
|
11
|
+
date: 2019-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: knock
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.7.
|
103
|
+
rubygems_version: 2.7.6
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Engine for api
|