thecore_backend_commons 3.1.3 → 3.1.4
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: 7497a63c6b2cf568f786b24734477b49d8a38a8b6dbec82f370ee1c02d463038
|
4
|
+
data.tar.gz: 4659432eab9e8b37b37c7e412010f82d8ba0aba879eadffc1ab22d79bae33dc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3da399e4ee0c80efb21447a3c50088a50e1a302531faf16d4f0fc8b0acc247b5f63968a738bc99dfd2b8b0f7ccca84f0242d0cdc2f365a9ae2d4d4c470910515
|
7
|
+
data.tar.gz: da3e94fa7c2c17da98d4c2aeac681a9fb59362d49738a6f17fd486ccfaa759767073e2a4dd70843ea1de1e0b04d3983a0b3fd606e8b2099276b36a75ddd00425
|
@@ -1,3 +1,3 @@
|
|
1
1
|
Rails.application.config.active_storage.configure :Disk, root: Rails.root.join("storage")
|
2
2
|
Rails.application.config.action_mailer.delivery_method = :smtp
|
3
|
-
Rails.application.config.action_cable.allowed_request_origins = [ ENV["FRONTEND_URL"].presence || /http:\/\/*/, ENV["BACKEND_URL"].presence || /http
|
3
|
+
Rails.application.config.action_cable.allowed_request_origins = [ ENV["FRONTEND_URL"].presence || /http:\/\/*/, ENV["BACKEND_URL"].presence || /http:\/\/*/, "https://localhost:8100" ].uniq
|
@@ -10,15 +10,23 @@ module ApplicationRecordConcern
|
|
10
10
|
after_rollback :message_ko
|
11
11
|
|
12
12
|
def validation_ko
|
13
|
-
ActionCable.server.broadcast("messages",
|
13
|
+
ActionCable.server.broadcast("messages", build_message(false, false, self.errors.full_messages.uniq)) if self.errors.any? && !is_model_forbidden
|
14
14
|
end
|
15
15
|
|
16
16
|
def message_ok
|
17
|
-
ActionCable.server.broadcast("messages",
|
17
|
+
ActionCable.server.broadcast("messages", build_message(true, true, [])) unless is_model_forbidden
|
18
18
|
end
|
19
19
|
|
20
20
|
def message_ko
|
21
|
-
ActionCable.server.broadcast("messages",
|
21
|
+
ActionCable.server.broadcast("messages", build_message(false, true, [])) unless is_model_forbidden
|
22
|
+
end
|
23
|
+
|
24
|
+
def is_model_forbidden
|
25
|
+
[ 'User', 'Role' ].include?(self.class.name)
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_message success, valid, errors
|
29
|
+
{ topic: :record, action: detect_action, class: self.class.name, success: success, valid: valid, errors: errors, record: self}
|
22
30
|
end
|
23
31
|
|
24
32
|
def detect_action
|
@@ -12,7 +12,10 @@ module CableConnectionConcern
|
|
12
12
|
protected
|
13
13
|
|
14
14
|
def find_verified_user # this checks whether a user is authenticated with devise
|
15
|
-
|
15
|
+
m = request.query_parameters["token"]
|
16
|
+
|
17
|
+
body = ::HashWithIndifferentAccess.new(::JWT.decode(m, ::Rails.application.credentials.dig(:secret_key_base).presence||ENV["SECRET_KEY_BASE"], false)[0]) rescue nil
|
18
|
+
if verified_user = (env['warden'].user.presence || User.find_by(id: body[:user_id]))
|
16
19
|
verified_user
|
17
20
|
else
|
18
21
|
reject_unauthorized_connection
|