Skip to content

Commit 8014369

Browse files
chore: merge 8.1.0 into beta
2 parents 18d7f75 + 1a73eb6 commit 8014369

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1074
-371
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- main
77
- beta
8+
- 7.x.x
89
pull_request:
910

1011
env:
@@ -72,7 +73,7 @@ jobs:
7273
name: Release
7374
runs-on: ubuntu-latest
7475
needs: [lint, test]
75-
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta')
76+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/7.x.x')
7677
steps:
7778
- uses: actions/checkout@v2
7879
with:

.releaserc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
branches: ['main', {name: 'beta', prerelease: true}],
2+
branches: ['main', '+([0-9])?(.{+([0-9]),x}).x', {name: 'beta', prerelease: true}],
33
plugins: [
44
[
55
'@semantic-release/commit-analyzer', {

CHANGELOG.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,129 @@
1+
# [8.1.0](https://github.com/ForestAdmin/forest-rails/compare/v8.0.17...v8.1.0) (2024-01-18)
2+
3+
4+
### Features
5+
6+
* add polymorphic associations support ([#640](https://github.com/ForestAdmin/forest-rails/issues/640)) ([2d43bc3](https://github.com/ForestAdmin/forest-rails/commit/2d43bc35c9085555cb3625a4325e427e80a5ec6a))
7+
8+
## [8.0.17](https://github.com/ForestAdmin/forest-rails/compare/v8.0.16...v8.0.17) (2023-12-05)
9+
10+
11+
### Bug Fixes
12+
13+
* security vulnerabilities RCE on 8.x.x ([#638](https://github.com/ForestAdmin/forest-rails/issues/638)) ([02679b5](https://github.com/ForestAdmin/forest-rails/commit/02679b584b84eda3d1f0be6e6482d130b53b4d19))
14+
15+
## [8.0.16](https://github.com/ForestAdmin/forest-rails/compare/v8.0.15...v8.0.16) (2023-11-16)
16+
17+
18+
### Bug Fixes
19+
20+
* **authentication:** return errors detail instead of generic error 500 ([#636](https://github.com/ForestAdmin/forest-rails/issues/636)) ([1a69e2f](https://github.com/ForestAdmin/forest-rails/commit/1a69e2f0ce308b060454ca98ab0d08fd8f14a862))
21+
22+
## [8.0.15](https://github.com/ForestAdmin/forest-rails/compare/v8.0.14...v8.0.15) (2023-10-23)
23+
24+
25+
### Bug Fixes
26+
27+
* **permissions:** fetch permissions return an exception when the server doesn't return an 200 response ([#635](https://github.com/ForestAdmin/forest-rails/issues/635)) ([9a7590b](https://github.com/ForestAdmin/forest-rails/commit/9a7590b5084ed4588fab09bd903822d05a0930fc))
28+
29+
## [8.0.14](https://github.com/ForestAdmin/forest-rails/compare/v8.0.13...v8.0.14) (2023-10-16)
30+
31+
32+
### Bug Fixes
33+
34+
* **logger:** format of the datetime ([#634](https://github.com/ForestAdmin/forest-rails/issues/634)) ([e356b83](https://github.com/ForestAdmin/forest-rails/commit/e356b838ebd8b426d189f076414841216b5198ab)), closes [#633](https://github.com/ForestAdmin/forest-rails/issues/633)
35+
36+
## [8.0.13](https://github.com/ForestAdmin/forest-rails/compare/v8.0.12...v8.0.13) (2023-10-05)
37+
38+
39+
### Bug Fixes
40+
41+
* destroy record with restriction on children ([#632](https://github.com/ForestAdmin/forest-rails/issues/632)) ([da1f8b6](https://github.com/ForestAdmin/forest-rails/commit/da1f8b6cf22d1701a83c40e2a79d056622566715)), closes [#630](https://github.com/ForestAdmin/forest-rails/issues/630)
42+
43+
## [8.0.12](https://github.com/ForestAdmin/forest-rails/compare/v8.0.11...v8.0.12) (2023-07-07)
44+
45+
46+
### Bug Fixes
47+
48+
* allow charts with dynamic query using record id ([#628](https://github.com/ForestAdmin/forest-rails/issues/628)) ([ff2e1b5](https://github.com/ForestAdmin/forest-rails/commit/ff2e1b5231393a8adfbef3b9c4abb135999e73ad))
49+
50+
## [8.0.11](https://github.com/ForestAdmin/forest-rails/compare/v8.0.10...v8.0.11) (2023-06-29)
51+
52+
53+
### Bug Fixes
54+
55+
* reporter error on dissociate action ([#627](https://github.com/ForestAdmin/forest-rails/issues/627)) ([edc45aa](https://github.com/ForestAdmin/forest-rails/commit/edc45aa0d09f06d89acec3ac835347129aa35d7c))
56+
57+
## [8.0.10](https://github.com/ForestAdmin/forest-rails/compare/v8.0.9...v8.0.10) (2023-06-19)
58+
59+
60+
### Bug Fixes
61+
62+
* **smartaction:** register custom endpoint for load/changes hooks ([#626](https://github.com/ForestAdmin/forest-rails/issues/626)) ([3d66b3b](https://github.com/ForestAdmin/forest-rails/commit/3d66b3bff1ddfb3476af3b6f54bcef6f15d79247))
63+
64+
## [8.0.9](https://github.com/ForestAdmin/forest-rails/compare/v8.0.8...v8.0.9) (2023-06-13)
65+
66+
67+
### Bug Fixes
68+
69+
* **permissions:** use correct collection name for model under module ([#624](https://github.com/ForestAdmin/forest-rails/issues/624)) ([e896763](https://github.com/ForestAdmin/forest-rails/commit/e8967631d93a8375de26f7707f8acba93f6ecc5c))
70+
71+
## [8.0.8](https://github.com/ForestAdmin/forest-rails/compare/v8.0.7...v8.0.8) (2023-05-23)
72+
73+
74+
### Bug Fixes
75+
76+
* **scope:** cast filters to json before merge with scope ([#622](https://github.com/ForestAdmin/forest-rails/issues/622)) ([b0e0196](https://github.com/ForestAdmin/forest-rails/commit/b0e01966158a37cadb2de7bf6ac177e53912d437))
77+
78+
## [8.0.7](https://github.com/ForestAdmin/forest-rails/compare/v8.0.6...v8.0.7) (2023-05-23)
79+
80+
81+
### Bug Fixes
82+
83+
* **operator:** replace the hard-coded duration by the duration variable ([#621](https://github.com/ForestAdmin/forest-rails/issues/621)) ([776f23d](https://github.com/ForestAdmin/forest-rails/commit/776f23d4afe47a0d41ca65abf9762e1c86504b3e))
84+
85+
## [8.0.6](https://github.com/ForestAdmin/forest-rails/compare/v8.0.5...v8.0.6) (2023-05-05)
86+
87+
88+
### Bug Fixes
89+
90+
* **hooks:** use exact namespace to prevent controller conflict ([#620](https://github.com/ForestAdmin/forest-rails/issues/620)) ([3e4e7d6](https://github.com/ForestAdmin/forest-rails/commit/3e4e7d64dcbe22f981ef21d82076765fd8a12ed3))
91+
92+
## [8.0.5](https://github.com/ForestAdmin/forest-rails/compare/v8.0.4...v8.0.5) (2023-05-04)
93+
94+
95+
### Bug Fixes
96+
97+
* **relation:** fix dissociate all records of relationship ([#618](https://github.com/ForestAdmin/forest-rails/issues/618)) ([861d76f](https://github.com/ForestAdmin/forest-rails/commit/861d76f2606f66d81df0cd31581950744a4b67a9))
98+
99+
## [8.0.4](https://github.com/ForestAdmin/forest-rails/compare/v8.0.3...v8.0.4) (2023-04-21)
100+
101+
102+
### Bug Fixes
103+
104+
* **action:** authorize all actions on development environment ([#617](https://github.com/ForestAdmin/forest-rails/issues/617)) ([72bec24](https://github.com/ForestAdmin/forest-rails/commit/72bec24fee8b0397c80a93654d28f52d9c20cc15))
105+
106+
## [8.0.3](https://github.com/ForestAdmin/forest-rails/compare/v8.0.2...v8.0.3) (2023-04-06)
107+
108+
109+
### Bug Fixes
110+
111+
* **permissions:** use forest collection name for check the permission ([#616](https://github.com/ForestAdmin/forest-rails/issues/616)) ([a35646f](https://github.com/ForestAdmin/forest-rails/commit/a35646f4c39cb151aed14e52e1be1099b1946fd9))
112+
113+
## [8.0.2](https://github.com/ForestAdmin/forest-rails/compare/v8.0.1...v8.0.2) (2023-03-22)
114+
115+
116+
### Bug Fixes
117+
118+
* developers can disable automatic schema send ([#614](https://github.com/ForestAdmin/forest-rails/issues/614)) ([97e1f06](https://github.com/ForestAdmin/forest-rails/commit/97e1f06d9442ed8faf8b22504caf76c8a4b50fe1))
119+
120+
## [8.0.1](https://github.com/ForestAdmin/forest-rails/compare/v8.0.0...v8.0.1) (2023-03-16)
121+
122+
123+
### Bug Fixes
124+
125+
* schema version generation for all versions ([#613](https://github.com/ForestAdmin/forest-rails/issues/613)) ([de72c6e](https://github.com/ForestAdmin/forest-rails/commit/de72c6e514ebb3483ffaf0fbc739acfeae0a56e7))
126+
1127
# [8.0.0](https://github.com/ForestAdmin/forest-rails/compare/v7.8.1...v8.0.0) (2023-03-14)
2128

3129

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ gemspec
1414
group :development, :test do
1515
gem 'byebug'
1616
gem 'rspec-rails'
17+
gem "timecop"
1718
end
1819

1920
group :test do

Gemfile.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
forest_liana (8.0.0)
4+
forest_liana (8.1.0)
55
arel-helpers
66
bcrypt
77
deepsort
@@ -231,6 +231,7 @@ GEM
231231
attr_required (>= 0.0.5)
232232
httpclient (>= 2.4)
233233
thor (1.2.1)
234+
timecop (0.9.6)
234235
timeout (0.3.1)
235236
tzinfo (2.0.5)
236237
concurrent-ruby (~> 1.0)
@@ -272,6 +273,7 @@ DEPENDENCIES
272273
rspec-rails
273274
simplecov (~> 0.17.0)
274275
sqlite3 (~> 1.4)
276+
timecop
275277
useragent
276278

277279
BUNDLED WITH

app/controllers/forest_liana/actions_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module ForestLiana
2-
class ActionsController < ApplicationController
2+
class ActionsController < ForestLiana::ApplicationController
33

44
def get_smart_action_hook_request
55
if params[:data] && params[:data][:attributes] && params[:data][:attributes][:collection_name]

app/controllers/forest_liana/application_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
module ForestLiana
55
class ApplicationController < ForestLiana::BaseController
66
rescue_from ForestLiana::Ability::Exceptions::AccessDenied, with: :render_error
7+
rescue_from ForestLiana::Errors::HTTP403Error, with: :render_error
78
rescue_from ForestLiana::Errors::HTTP422Error, with: :render_error
89

910
def self.papertrail?

app/controllers/forest_liana/associations_controller.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@ def associate
7272

7373
def dissociate
7474
begin
75-
dissociator = HasManyDissociator.new(@resource, @association, params)
75+
dissociator = HasManyDissociator.new(@resource, @association, params, forest_user)
7676
dissociator.perform
7777

7878
head :no_content
7979
rescue => error
80-
FOREST_LOGGER.error "Association Associate error: #{error}\n#{format_stacktrace(error)}"
80+
FOREST_REPORTER.report error
81+
FOREST_LOGGER.error "Association Dissociate error: #{error}\n#{format_stacktrace(error)}"
8182
internal_server_error
8283
end
8384
end

app/controllers/forest_liana/authentication_controller.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def start_authentication
3939
end
4040

4141
def authentication_callback
42+
return authentication_exception if params.key?(:error)
43+
4244
begin
4345
token = @authentication_service.verify_code_and_generate_token(params)
4446

@@ -55,6 +57,21 @@ def authentication_callback
5557
end
5658
end
5759

60+
def authentication_exception
61+
begin
62+
raise ForestLiana::Errors::AuthenticationOpenIdClientException.new(params[:error], params[:error_description], params[:state])
63+
rescue => error
64+
FOREST_REPORTER.report error
65+
FOREST_LOGGER.error "AuthenticationOpenIdClientException: #{error.error_description}"
66+
67+
render json: {
68+
error: error.error,
69+
error_description: error.error_description,
70+
state: error.state
71+
}, status: :unauthorized
72+
end
73+
end
74+
5875
def logout
5976
begin
6077
if cookies.has_key?(:forest_session_token)

app/controllers/forest_liana/resources_controller.rb

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,20 @@ def update
129129

130130
def destroy
131131
forest_authorize!('delete', forest_user, @resource)
132-
begin
132+
begin
133133
collection_name = ForestLiana.name_for(@resource)
134134
scoped_records = ForestLiana::ScopeManager.apply_scopes_on_records(@resource, forest_user, collection_name, params[:timezone])
135135

136136
unless scoped_records.exists?(params[:id])
137137
return render serializer: nil, json: { status: 404 }, status: :not_found
138138
end
139139

140-
scoped_records.destroy(params[:id])
141-
142-
head :no_content
140+
if scoped_records.destroy(params[:id])
141+
head :no_content
142+
else
143+
restrict_error = ActiveRecord::DeleteRestrictionError.new
144+
render json: { errors: [{ status: :bad_request, detail: restrict_error.message }] }, status: :bad_request
145+
end
143146
rescue => error
144147
FOREST_REPORTER.report error
145148
FOREST_LOGGER.error "Record Destroy error: #{error}\n#{format_stacktrace(error)}"
@@ -151,9 +154,14 @@ def destroy_bulk
151154
forest_authorize!('delete', forest_user, @resource)
152155
begin
153156
ids = ForestLiana::ResourcesGetter.get_ids_from_request(params, forest_user)
154-
@resource.destroy(ids) if ids&.any?
155-
156-
head :no_content
157+
@resource.transaction do
158+
ids.each do |id|
159+
record = @resource.find(id)
160+
record.destroy!
161+
end
162+
end
163+
rescue ActiveRecord::RecordNotDestroyed => error
164+
render json: { errors: [{ status: :bad_request, detail: error.message }] }, status: :bad_request
157165
rescue => error
158166
FOREST_REPORTER.report error
159167
FOREST_LOGGER.error "Records Destroy error: #{error}\n#{format_stacktrace(error)}"

0 commit comments

Comments
 (0)