eco-helpers 2.4.2 → 2.4.3
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/CHANGELOG.md +8 -1
- data/lib/eco/api/microcases/take_email_from_account.rb +26 -5
- data/lib/eco/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84e0b3626647d968a77ecc7dbc9dbe052be392ff7590f9f32c2402d4a0fdb45b
|
4
|
+
data.tar.gz: cfd6e253e91d50bd62ffb4cbad8556214a3519ccaf9fdd148c681170ad150466
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4162b785935a8f161ad5030e8ffbd72defd3ed10f50b6d4944b219c0faed84f5cd57efee5a1c43ed41c2f4efdbbcb5ab7356c426dbecd2ebaca2a0da79bba90a
|
7
|
+
data.tar.gz: 5c5ad42b25f53b92fcac214555fb7b2ab9b5af0c033367b375b6ae55334ce0ffa7ecca74d05bac7dd3a75aba7761d9f7be91d5fab44310eb664eeed3df758f83
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [2.4.
|
4
|
+
## [2.4.4] - 2023-03-xx
|
5
5
|
|
6
6
|
### Added
|
7
7
|
### Changed
|
8
8
|
### Fixed
|
9
9
|
|
10
|
+
## [2.4.3] - 2023-03-23
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
- `Eco::API::MicroCases#take_email_from_account` it was failing at the very (when restoring the original account)
|
14
|
+
- Comes from back-end issue. Adding account with preferences.kiosk_enabled would return:
|
15
|
+
- `{"errors"=>["account > preferences > kiosk_enabled is an unknown field"]}`
|
16
|
+
|
10
17
|
## [2.4.2] - 2023-03-17
|
11
18
|
|
12
19
|
### Fixed
|
@@ -36,27 +36,33 @@ module Eco
|
|
36
36
|
return false if dest_email.to_s.strip.empty?
|
37
37
|
end
|
38
38
|
|
39
|
-
account_json =
|
39
|
+
account_json = _take_email_account_json(account)
|
40
40
|
person.email = account_email
|
41
41
|
|
42
42
|
if success = _take_email_remove_account!(person, context: context)
|
43
43
|
if success = _take_email_acquire_account!(person, target_email, account: {}, context: context)
|
44
44
|
if success = _take_email_email_free_up!(person, dest_email: dest_email, context: context)
|
45
45
|
if success = _take_email_remove_account!(person, context: context)
|
46
|
+
# Bring back the original account
|
46
47
|
if success = _take_email_acquire_account!(person, account_email, account: account_json, context: context)
|
48
|
+
success = true
|
47
49
|
person.email = target_email
|
48
50
|
end
|
49
51
|
end
|
50
52
|
else # free up target email
|
51
53
|
# restore
|
52
|
-
|
53
|
-
|
54
|
+
reverted = false
|
55
|
+
if reverted ||= _take_email_remove_account!(person, context: context)
|
56
|
+
reverted ||= _take_email_acquire_account!(person, account_email, account: account_json, context: context)
|
54
57
|
end
|
58
|
+
puts "Could not revert back to the original account #{person.identify}" unless reverted
|
55
59
|
success = false
|
56
60
|
end
|
57
61
|
else # aquire other account
|
58
62
|
# restore
|
59
|
-
_take_email_acquire_account!(person, account_email, account: account_json, context: context)
|
63
|
+
unless _take_email_acquire_account!(person, account_email, account: account_json, context: context)
|
64
|
+
puts "Could not bring back the original account we want to update the email to '#{target_email}' #{person.identify}"
|
65
|
+
end
|
60
66
|
success = false
|
61
67
|
end
|
62
68
|
end
|
@@ -65,6 +71,21 @@ module Eco
|
|
65
71
|
|
66
72
|
private
|
67
73
|
|
74
|
+
def _take_email_account_json(account)
|
75
|
+
JSON.parse(account.to_json).tap do |hash|
|
76
|
+
hash.delete("user_id")
|
77
|
+
hash.delete("permissions_merged")
|
78
|
+
hash.delete("permissions_preset")
|
79
|
+
hash.delete("prefilter")
|
80
|
+
if pref = hash["preferences"]
|
81
|
+
hash["preferences"] = pref.reject do |attr, value|
|
82
|
+
attr.start_with?("kiosk")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Bring the account of the `target_email` taken, so we can change the email of this account
|
68
89
|
def _take_email_acquire_account!(person, target_email, account: {}, context: "Session")
|
69
90
|
person.account = account
|
70
91
|
person.account.send_invites = false
|
@@ -72,6 +93,7 @@ module Eco
|
|
72
93
|
micro.person_update!(person, reason: "bring account with email '#{target_email}'", context: context)
|
73
94
|
end
|
74
95
|
|
96
|
+
# Free up the email (`target_email`) of the account that has it taken to `dest_email`
|
75
97
|
def _take_email_email_free_up!(person, dest_email:, target_email: nil, context: "Session")
|
76
98
|
target_email ||= person.email
|
77
99
|
person.email = dest_email.is_a?(Proc)? dest_email.call(target_email) : dest_email
|
@@ -83,7 +105,6 @@ module Eco
|
|
83
105
|
person.account = nil
|
84
106
|
micro.person_update!(person, reason: "remove account", context: context)
|
85
107
|
end
|
86
|
-
|
87
108
|
end
|
88
109
|
end
|
89
110
|
end
|
data/lib/eco/version.rb
CHANGED