model_driven_api 2.3.18 → 2.4.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ebbf8c8f9cb0482195ef574b6bab41ec475f902adbf03de770919d2ac0fbd40
|
4
|
+
data.tar.gz: cc1a6d816f3d2a448a80dc91bdd4aab17d83aa303333241a8a401ca4b4b0dcd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '01395a025a0443d82d5e8642b5a83677d4baa85fc09139f90f333c8673a95060afce395adca76e7d0f515f32749d728fa3d5be67c75fb56807b62eeb063ab515'
|
7
|
+
data.tar.gz: 9ec3c4dfed6b399e633cbf8adb208296093057fac04a5e7754c7b5947102e8d14b14c3582c536ecba8f1fa35791400ab4e902991bd5790ce69f4005609847495
|
@@ -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
|
data/lib/json_web_token.rb
CHANGED
@@ -10,7 +10,7 @@ class JsonWebToken
|
|
10
10
|
|
11
11
|
def decode(token)
|
12
12
|
# Check if the passed token is present and valid into the UsedToken
|
13
|
-
raise "Token is invalidated by new login" unless UsedToken.exists?(token: token, is_valid: true)
|
13
|
+
raise "Token is invalidated by new login" unless UsedToken.exists?(token: token, is_valid: true) if ENV["ALLOW_MULTISESSIONS"] == "false"
|
14
14
|
body = ::JWT.decode(token, ::Rails.application.credentials.dig(:secret_key_base).presence||ENV["SECRET_KEY_BASE"])[0]
|
15
15
|
::HashWithIndifferentAccess.new body
|
16
16
|
rescue
|
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.
|
4
|
+
version: 2.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-07 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: []
|