model_driven_api 2.3.19 → 2.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/app/commands/authenticate_user.rb +1 -1
- data/app/controllers/api/v2/application_controller.rb +2 -1
- data/app/controllers/api/v2/authentication_controller.rb +3 -2
- data/app/controllers/api/v2/info_controller.rb +5 -0
- data/config/routes.rb +1 -0
- 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: 2f587fb3dc87ca59c5a9cfa3bd03137481b64bb691d69324b956a68f43316018
|
4
|
+
data.tar.gz: 92ad2b21cd10fceab0c7b0d5439048a9d01fdfa8f8d8c64046c1e451279666d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74e867b8007e9d8234321cb569e4e2d5505dc2347ba563a9e71dfc1e8a7ff30a3eea4264c6e79c51a5b3e74d8a70b1b220064530c6dfa9962dc05fba57066440
|
7
|
+
data.tar.gz: 8bcf5ae78e32f788fd62ec66df1b3d46614b47b74c59e0a9d05f72d9efa8cf8fbc2996f67f23a9d1428e700203d54ae1a1af12957c051e49f3378bda7e5e7733
|
data/README.md
CHANGED
@@ -140,6 +140,14 @@ Once the JWT has been retrieved, the **Authenticated Request**s must use it in a
|
|
140
140
|
|
141
141
|
```
|
142
142
|
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE1OTA3NzQyMzR9.Z-1yECp55VD560UcB7gIhgVWJNjn8HUerG5s4TVSRko
|
143
|
+
```
|
144
|
+
|
145
|
+
#### Token Refresh
|
146
|
+
|
147
|
+
If issued during the token validity period, this will just return a new JWT to be used during following API request.
|
148
|
+
|
149
|
+
```bash
|
150
|
+
:GET http://localhost:3000/api/v2/info/heartbeat
|
143
151
|
```
|
144
152
|
|
145
153
|
### CRUD Actions
|
@@ -299,7 +307,7 @@ Something like this can be retrieved:
|
|
299
307
|
By issuing this GET request:
|
300
308
|
|
301
309
|
```bash
|
302
|
-
GET http://localhost:3000/api/v2/info/
|
310
|
+
GET http://localhost:3000/api/v2/info/schema
|
303
311
|
```
|
304
312
|
|
305
313
|
You will get something like:
|
@@ -23,7 +23,7 @@ class AuthenticateUser
|
|
23
23
|
# Since this is a new login and I don't care from where it comes, new logins always
|
24
24
|
# Invalidate older tokens
|
25
25
|
UsedToken.where(user_id: api_user.id).update(is_valid: false) if ENV["ALLOW_MULTISESSIONS"] == "false"
|
26
|
-
return result
|
26
|
+
return {jwt: result, user: current_u}
|
27
27
|
end
|
28
28
|
nil
|
29
29
|
end
|
@@ -84,7 +84,8 @@ class Api::V2::ApplicationController < ActionController::API
|
|
84
84
|
return render json: result, status: 200 if status == true
|
85
85
|
|
86
86
|
# Normal Update Action
|
87
|
-
|
87
|
+
# Raisl 6 vs Rails 6.1
|
88
|
+
@record.respond_to?('update_attributes!') ? @record.update_attributes!(@body) : @record.update!(@body)
|
88
89
|
render json: @record.to_json(json_attrs), status: 200
|
89
90
|
end
|
90
91
|
|
@@ -5,8 +5,9 @@ class Api::V2::AuthenticationController < ActionController::API
|
|
5
5
|
command = !params[:atoken].blank? && User.column_names.include?("access_token") ? AuthenticateUser.call(access_token: params[:atoken]) : AuthenticateUser.call(email: params[:auth][:email], password: params[:auth][:password])
|
6
6
|
|
7
7
|
if command.success?
|
8
|
-
response.headers['Token'] = command.result
|
9
|
-
head :ok
|
8
|
+
response.headers['Token'] = command.result[:jwt]
|
9
|
+
# head :ok
|
10
|
+
render json: command.result[:user].to_json(User.json_attrs), status: 200
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -73,4 +73,9 @@ class Api::V2::InfoController < Api::V2::ApplicationController
|
|
73
73
|
end
|
74
74
|
render json: pivot.to_json, status: 200
|
75
75
|
end
|
76
|
+
|
77
|
+
def settings
|
78
|
+
render json: ThecoreSettings::Setting.pluck(:ns, :key, :raw).inject({}){|result, array| (result[array.first] ||= {})[array.second] = array.third; result }.to_json, status: 200
|
79
|
+
end
|
80
|
+
|
76
81
|
end
|
data/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: model_driven_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3
|
4
|
+
version: 2.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thecore_backend_commons
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '1.2'
|
125
125
|
description: Ruby on Rails REST APIs built by convention using the DB schema as the
|
126
|
-
foundation.
|
126
|
+
foundation, please see README for mode of use.
|
127
127
|
email:
|
128
128
|
- gabriele.tassoni@gmail.com
|
129
129
|
executables: []
|