decidim-core 0.31.7 → 0.31.9
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/app/cells/decidim/address_cell.rb +7 -3
- data/app/cells/decidim/card_metadata_cell.rb +3 -1
- data/app/cells/decidim/content_blocks/participatory_space_main_data/title.erb +1 -14
- data/app/cells/decidim/date_range/show.erb +6 -6
- data/app/cells/decidim/date_range_cell.rb +7 -2
- data/app/cells/decidim/following_cell.rb +1 -1
- data/app/cells/decidim/nav_links/show.erb +3 -1
- data/app/cells/decidim/participatory_space_private_user/show.erb +1 -1
- data/app/cells/decidim/share_text_widget/modal.erb +1 -0
- data/app/cells/decidim/share_widget/modal.erb +1 -0
- data/app/cells/decidim/share_widget/qr_code_modal.erb +2 -4
- data/app/commands/decidim/create_follow.rb +3 -7
- data/app/commands/decidim/create_omniauth_registration.rb +19 -7
- data/app/commands/decidim/create_user_report.rb +1 -1
- data/app/commands/decidim/destroy_account.rb +6 -6
- data/app/commands/decidim/destroy_ephemeral_user.rb +2 -0
- data/app/commands/decidim/invite_user.rb +1 -1
- data/app/commands/decidim/multiple_attachments_methods.rb +17 -3
- data/app/commands/decidim/update_resources_taxonomies.rb +2 -1
- data/app/controllers/concerns/decidim/devise_authentication_methods.rb +4 -0
- data/app/controllers/concerns/decidim/devise_controllers.rb +4 -0
- data/app/controllers/concerns/decidim/direct_upload.rb +12 -6
- data/app/controllers/concerns/decidim/disable_redirection_to_external_host.rb +2 -0
- data/app/controllers/concerns/decidim/filter_resource.rb +2 -0
- data/app/controllers/concerns/decidim/impersonate_users.rb +4 -4
- data/app/controllers/concerns/decidim/locale_switcher.rb +62 -11
- data/app/controllers/concerns/decidim/needs_organization.rb +15 -0
- data/app/controllers/concerns/decidim/needs_permission.rb +22 -10
- data/app/controllers/concerns/decidim/onboarding_action_methods.rb +2 -0
- data/app/controllers/concerns/decidim/paginable.rb +7 -3
- data/app/controllers/concerns/decidim/payload_info.rb +2 -0
- data/app/controllers/concerns/decidim/resource_versions_concern.rb +14 -0
- data/app/controllers/decidim/amendments_controller.rb +34 -6
- data/app/controllers/decidim/application_controller.rb +2 -6
- data/app/controllers/decidim/authorization_modals_controller.rb +3 -1
- data/app/controllers/decidim/components/base_controller.rb +2 -0
- data/app/controllers/decidim/devise/passwords_controller.rb +8 -0
- data/app/controllers/decidim/doorkeeper/authorizations_controller.rb +10 -4
- data/app/controllers/decidim/doorkeeper/credentials_controller.rb +6 -1
- data/app/controllers/decidim/favicon_controller.rb +9 -0
- data/app/controllers/decidim/free_resource_authorization_modals_controller.rb +2 -0
- data/app/controllers/decidim/gamification/badges_controller.rb +2 -0
- data/app/controllers/decidim/homepage_controller.rb +4 -1
- data/app/controllers/decidim/likes_controller.rb +1 -1
- data/app/controllers/decidim/links_controller.rb +2 -0
- data/app/controllers/decidim/manifests_controller.rb +2 -0
- data/app/controllers/decidim/messaging/conversations_controller.rb +11 -5
- data/app/controllers/decidim/newsletters_controller.rb +4 -0
- data/app/controllers/decidim/notifications_subscriptions_controller.rb +4 -0
- data/app/controllers/decidim/offline_controller.rb +5 -1
- data/app/controllers/decidim/open_data_controller.rb +5 -1
- data/app/controllers/decidim/pages_controller.rb +31 -3
- data/app/controllers/decidim/private_downloads_controller.rb +2 -0
- data/app/controllers/decidim/profiles_controller.rb +11 -1
- data/app/controllers/decidim/qr_controller.rb +3 -1
- data/app/controllers/decidim/resource_autocomplete_controller.rb +2 -0
- data/app/controllers/decidim/searches_controller.rb +2 -0
- data/app/controllers/decidim/short_links_controller.rb +4 -0
- data/app/controllers/decidim/static_map_controller.rb +2 -0
- data/app/controllers/decidim/timeouts_controller.rb +4 -0
- data/app/controllers/decidim/tos_controller.rb +2 -0
- data/app/controllers/decidim/upload_validations_controller.rb +4 -2
- data/app/controllers/decidim/user_activities_controller.rb +2 -0
- data/app/forms/decidim/upload_validation_form.rb +16 -10
- data/app/helpers/concerns/decidim/user_role_checker.rb +35 -10
- data/app/helpers/decidim/cells_paginate_helper.rb +0 -5
- data/app/helpers/decidim/layout_helper.rb +1 -0
- data/app/helpers/decidim/orders_helper.rb +8 -6
- data/app/helpers/decidim/paginate_helper.rb +27 -2
- data/app/helpers/decidim/sanitize_helper.rb +11 -1
- data/app/helpers/decidim/url_helper.rb +35 -0
- data/app/jobs/decidim/application_job.rb +4 -0
- data/app/jobs/decidim/open_data_job.rb +21 -5
- data/app/models/decidim/action_log.rb +7 -1
- data/app/models/decidim/authorization.rb +24 -0
- data/app/models/decidim/component.rb +10 -0
- data/app/models/decidim/like.rb +1 -1
- data/app/models/decidim/oauth_application.rb +1 -0
- data/app/models/decidim/user.rb +1 -0
- data/app/models/decidim/user_base_entity.rb +1 -1
- data/app/packs/src/decidim/callout.js +10 -0
- data/app/packs/src/decidim/callout.test.js +32 -0
- data/app/packs/src/decidim/controllers/accordion/accordion.test.js +64 -0
- data/app/packs/src/decidim/controllers/accordion/controller.js +43 -0
- data/app/packs/src/decidim/datepicker/datepicker_functions.js +54 -30
- data/app/packs/src/decidim/datepicker/form_datepicker.js +18 -2
- data/app/packs/src/decidim/datepicker/generate_datepicker.js +16 -8
- data/app/packs/src/decidim/datepicker/generate_timepicker.js +5 -3
- data/app/packs/src/decidim/datepicker/test/date.test.js +8 -0
- data/app/packs/src/decidim/datepicker/test/time.test.js +39 -24
- data/app/packs/src/decidim/utilities/dom.js +2 -2
- data/app/packs/stylesheets/decidim/_content_blocks.scss +4 -10
- data/app/packs/stylesheets/decidim/_conversations.scss +0 -8
- data/app/packs/stylesheets/decidim/_datepicker.scss +3 -3
- data/app/packs/stylesheets/decidim/_modal.scss +16 -8
- data/app/packs/stylesheets/decidim/_modal_share.scss +0 -22
- data/app/packs/stylesheets/decidim/_participatory_spaces.scss +11 -1
- data/app/packs/stylesheets/decidim/_rich_text.scss +12 -9
- data/app/packs/stylesheets/decidim/_spinner.scss +16 -0
- data/app/packs/stylesheets/decidim/_tom_select.scss +1 -1
- data/app/packs/stylesheets/decidim/_typography.scss +5 -2
- data/app/packs/stylesheets/decidim/legacy/email.scss +0 -5
- data/app/permissions/decidim/permissions.rb +20 -0
- data/app/presenters/decidim/admin_log/component_presenter.rb +1 -1
- data/app/presenters/decidim/log/base_presenter.rb +20 -2
- data/app/presenters/decidim/log/user_presenter.rb +2 -2
- data/app/serializers/decidim/exporters/open_data_blocked_user_serializer.rb +11 -2
- data/app/serializers/decidim/exporters/open_data_moderation_serializer.rb +25 -1
- data/app/services/decidim/action_logger.rb +97 -29
- data/app/services/decidim/svg_content_validator.rb +889 -0
- data/app/uploaders/decidim/application_uploader.rb +2 -2
- data/app/validators/uploader_image_content_validator.rb +282 -0
- data/app/views/decidim/application/_radio_accordion.html.erb +1 -5
- data/app/views/decidim/manifests/show.json.erb +25 -22
- data/app/views/decidim/messaging/conversations/create.js.erb +1 -3
- data/app/views/decidim/shared/_login_modal.html.erb +12 -14
- data/app/views/decidim/shared/_results_per_page.html.erb +1 -1
- data/app/views/layouts/decidim/_mailer_logo.html.erb +1 -1
- data/config/initializers/rack_attack.rb +10 -0
- data/config/locales/bg.yml +1 -4
- data/config/locales/ca-IT.yml +8 -4
- data/config/locales/ca.yml +10 -6
- data/config/locales/cs.yml +16 -4
- data/config/locales/de.yml +62 -6
- data/config/locales/en.yml +8 -4
- data/config/locales/es-MX.yml +8 -4
- data/config/locales/es-PY.yml +8 -4
- data/config/locales/es.yml +14 -10
- data/config/locales/eu.yml +165 -164
- data/config/locales/fi-plain.yml +3 -3
- data/config/locales/fi.yml +3 -3
- data/config/locales/fr-CA.yml +8 -4
- data/config/locales/fr.yml +8 -4
- data/config/locales/gl.yml +1440 -33
- data/config/locales/hu.yml +0 -1
- data/config/locales/it.yml +0 -2
- data/config/locales/ja.yml +4 -4
- data/config/locales/pl.yml +1 -4
- data/config/locales/pt-BR.yml +1 -4
- data/config/locales/ro-RO.yml +0 -3
- data/config/locales/sk.yml +51 -4
- data/config/locales/sv.yml +50 -13
- data/config/locales/tr-TR.yml +1 -3
- data/db/migrate/20250523104311_move_cta_to_hero_content_block.rb +1 -1
- data/db/migrate/20250527122040_move_highlighted_content_banner_settings_to_content_block.rb +3 -0
- data/db/migrate/20260909000000_add_failed_attempts_and_locked_at_to_decidim_authorizations.rb +8 -0
- data/db/migrate/20261007090000_make_user_optional_in_action_logs.rb +12 -0
- data/decidim-core.gemspec +1 -1
- data/lib/decidim/content_renderers/mention_resource_renderer.rb +6 -3
- data/lib/decidim/core/test/factories.rb +2 -2
- data/lib/decidim/core/test/shared_examples/participatory_space_members_page_examples.rb +77 -0
- data/lib/decidim/core/test/shared_examples/participatory_space_members_shared_examples.rb +85 -6
- data/lib/decidim/core/test/shared_examples/versions_controller_examples.rb +23 -1
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/core.rb +10 -1
- data/lib/decidim/has_upload_validations.rb +1 -0
- data/lib/decidim/legacy_form_builder.rb +4 -0
- data/lib/decidim/maintenance/import_models/scope.rb +2 -1
- data/lib/decidim/maintenance/taxonomy_importer.rb +4 -1
- data/lib/decidim/query_extensions.rb +2 -0
- data/lib/decidim/view_model.rb +1 -0
- data/lib/tasks/decidim_open_data_tasks.rake +7 -0
- metadata +22 -10
|
@@ -41,19 +41,11 @@ module Decidim
|
|
|
41
41
|
component_settings: try(:component_settings),
|
|
42
42
|
current_organization: try(:current_organization),
|
|
43
43
|
current_component: try(:current_component),
|
|
44
|
-
share_token:
|
|
44
|
+
share_token: store_share_token
|
|
45
45
|
}
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
if Rails.env.development?
|
|
50
|
-
Rails.logger.debug "==========="
|
|
51
|
-
Rails.logger.debug [permission_scope, action, subject, permission_class_chain].map(&:inspect).join("\n")
|
|
52
|
-
Rails.logger.debug "==========="
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
raise Decidim::ActionForbidden unless allowed_to?(action, subject, extra_context)
|
|
56
|
-
end
|
|
48
|
+
public
|
|
57
49
|
|
|
58
50
|
# rubocop:disable Metrics/ParameterLists
|
|
59
51
|
def allowed_to?(action, subject, extra_context = {}, chain = permission_class_chain, user = current_user, scope = nil)
|
|
@@ -76,6 +68,18 @@ module Decidim
|
|
|
76
68
|
allowed_to?(action, subject, extra_context, chain, user, :admin)
|
|
77
69
|
end
|
|
78
70
|
|
|
71
|
+
protected
|
|
72
|
+
|
|
73
|
+
def enforce_permission_to(action, subject, extra_context = {})
|
|
74
|
+
if Rails.env.development?
|
|
75
|
+
Rails.logger.debug "==========="
|
|
76
|
+
Rails.logger.debug [permission_scope, action, subject, permission_class_chain].map(&:inspect).join("\n")
|
|
77
|
+
Rails.logger.debug "==========="
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
raise Decidim::ActionForbidden unless allowed_to?(action, subject, extra_context)
|
|
81
|
+
end
|
|
82
|
+
|
|
79
83
|
def permission_class_chain
|
|
80
84
|
raise "Please, make this method return an array of permission classes"
|
|
81
85
|
end
|
|
@@ -83,6 +87,14 @@ module Decidim
|
|
|
83
87
|
def permission_scope
|
|
84
88
|
raise "Please, make this method return a symbol"
|
|
85
89
|
end
|
|
90
|
+
|
|
91
|
+
private
|
|
92
|
+
|
|
93
|
+
def store_share_token
|
|
94
|
+
session[:share_token] = params[:share_token] if params.has_key?(:share_token)
|
|
95
|
+
|
|
96
|
+
session[:share_token].presence
|
|
97
|
+
end
|
|
86
98
|
end
|
|
87
99
|
end
|
|
88
100
|
end
|
|
@@ -13,9 +13,7 @@ module Decidim
|
|
|
13
13
|
helper_method :per_page, :page_offset
|
|
14
14
|
helper Decidim::PaginateHelper
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
resources.page(params[:page]).per(per_page)
|
|
18
|
-
end
|
|
16
|
+
protected
|
|
19
17
|
|
|
20
18
|
def per_page
|
|
21
19
|
if OPTIONS.include?(params[:per_page])
|
|
@@ -31,6 +29,12 @@ module Decidim
|
|
|
31
29
|
def page_offset
|
|
32
30
|
[params[:page].to_i - 1, 0].max * per_page
|
|
33
31
|
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def paginate(resources)
|
|
36
|
+
resources.page(params[:page]).per(per_page)
|
|
37
|
+
end
|
|
34
38
|
end
|
|
35
39
|
end
|
|
36
40
|
end
|
|
@@ -11,11 +11,25 @@ module Decidim
|
|
|
11
11
|
helper_method :current_version, :versioned_resource
|
|
12
12
|
|
|
13
13
|
def show
|
|
14
|
+
enforce_permission_to(*versioned_resource_permission)
|
|
15
|
+
|
|
14
16
|
raise ActionController::RoutingError, "Not found" unless current_version
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
private
|
|
18
20
|
|
|
21
|
+
# The versions must honour the same `:read` permission as their resource,
|
|
22
|
+
# so a resource that is hidden, private, deleted or unpublished (and
|
|
23
|
+
# therefore cannot be read on its own) cannot be reached through its
|
|
24
|
+
# versions either.
|
|
25
|
+
def versioned_resource_permission
|
|
26
|
+
resource = versioned_resource
|
|
27
|
+
raise ActionController::RoutingError, "Not found" unless resource
|
|
28
|
+
|
|
29
|
+
subject = resource.model_name.element.to_sym
|
|
30
|
+
[:read, subject, { subject => resource }]
|
|
31
|
+
end
|
|
32
|
+
|
|
19
33
|
# Overwrite this method in your controller to define how to find the
|
|
20
34
|
# versioned resource.
|
|
21
35
|
def versioned_resource
|
|
@@ -21,14 +21,14 @@ module Decidim
|
|
|
21
21
|
if amendment_draft
|
|
22
22
|
redirect_to edit_draft_amend_path(amendment_draft)
|
|
23
23
|
else
|
|
24
|
-
@form = form(Decidim::Amendable::CreateForm).from_params(
|
|
24
|
+
@form = form(Decidim::Amendable::CreateForm).from_params(create_params)
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def create
|
|
29
29
|
enforce_permission_to :create, :amendment, current_component: amendable.component
|
|
30
30
|
|
|
31
|
-
@form = form(Decidim::Amendable::CreateForm).from_params(
|
|
31
|
+
@form = form(Decidim::Amendable::CreateForm).from_params(create_params)
|
|
32
32
|
|
|
33
33
|
Decidim::Amendable::CreateDraft.call(@form) do
|
|
34
34
|
on(:ok) do |amendment|
|
|
@@ -144,13 +144,13 @@ module Decidim
|
|
|
144
144
|
def review
|
|
145
145
|
enforce_permission_to :accept, :amendment, amendable:, current_component: amendable.component
|
|
146
146
|
|
|
147
|
-
@form = form(Decidim::Amendable::ReviewForm).from_params(
|
|
147
|
+
@form = form(Decidim::Amendable::ReviewForm).from_params(review_params)
|
|
148
148
|
end
|
|
149
149
|
|
|
150
150
|
def accept
|
|
151
151
|
enforce_permission_to :accept, :amendment, amendable:, current_component: amendable.component
|
|
152
152
|
|
|
153
|
-
@form = form(Decidim::Amendable::ReviewForm).from_params(
|
|
153
|
+
@form = form(Decidim::Amendable::ReviewForm).from_params(review_params)
|
|
154
154
|
|
|
155
155
|
Decidim::Amendable::Accept.call(@form) do
|
|
156
156
|
on(:ok) do |emendation|
|
|
@@ -189,12 +189,40 @@ module Decidim
|
|
|
189
189
|
params[:amendable_gid] || params.dig(:amendment, :amendable_gid)
|
|
190
190
|
end
|
|
191
191
|
|
|
192
|
+
# Binds the create form to the already-checked amendable, so a conflicting
|
|
193
|
+
# nested `amendment[amendable_gid]` cannot select another resource.
|
|
194
|
+
def create_params
|
|
195
|
+
params.deep_merge(amendment: { amendable_gid: amendable&.to_sgid&.to_s })
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Binds the review form to the amendment from the route, so a nested
|
|
199
|
+
# `amendment[id]` cannot select a different amendment.
|
|
200
|
+
def review_params
|
|
201
|
+
params.deep_merge(amendment: { id: amendment&.id })
|
|
202
|
+
end
|
|
203
|
+
|
|
192
204
|
def amendment
|
|
193
|
-
@amendment ||= Decidim::Amendment.find_by(id: params[:id])
|
|
205
|
+
@amendment ||= Decidim::Amendment.find_by(id: params[:id]) # rubocop:disable Decidim/OrganizationScopedFinder -- Amendment has no organization column; #amendable validates the owning resource
|
|
194
206
|
end
|
|
195
207
|
|
|
196
208
|
def amendable
|
|
197
|
-
@amendable ||=
|
|
209
|
+
@amendable ||= begin
|
|
210
|
+
# Existing amendments must always resolve their own amendable, so a
|
|
211
|
+
# foreign amendment cannot be authorized through a local
|
|
212
|
+
# `amendable_gid` supplied alongside its id. The signed resource is
|
|
213
|
+
# only used when creating an amendment.
|
|
214
|
+
resource = if creating_amendment?
|
|
215
|
+
GlobalID::Locator.locate_signed(amendable_gid)
|
|
216
|
+
else
|
|
217
|
+
amendment&.amendable
|
|
218
|
+
end
|
|
219
|
+
ensure_in_organization!(resource)
|
|
220
|
+
resource
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def creating_amendment?
|
|
225
|
+
%w(new create).include?(action_name)
|
|
198
226
|
end
|
|
199
227
|
|
|
200
228
|
def emendation
|
|
@@ -28,6 +28,7 @@ module Decidim
|
|
|
28
28
|
include ActiveStorage::SetCurrent
|
|
29
29
|
include OnboardingActionMethods
|
|
30
30
|
include EphemeralSessionChecker
|
|
31
|
+
include Decidim::UrlHelper
|
|
31
32
|
|
|
32
33
|
helper Decidim::MetaTagsHelper
|
|
33
34
|
helper Decidim::DecidimFormHelper
|
|
@@ -44,6 +45,7 @@ module Decidim
|
|
|
44
45
|
helper Decidim::SocialShareButtonHelper
|
|
45
46
|
helper Decidim::FiltersHelper
|
|
46
47
|
helper Decidim::OnboardingActionHelper
|
|
48
|
+
helper Decidim::UrlHelper
|
|
47
49
|
|
|
48
50
|
register_permissions(::Decidim::ApplicationController,
|
|
49
51
|
::Decidim::Admin::Permissions,
|
|
@@ -59,12 +61,6 @@ module Decidim
|
|
|
59
61
|
|
|
60
62
|
skip_before_action :disable_http_caching, unless: :user_signed_in?
|
|
61
63
|
|
|
62
|
-
def store_share_token
|
|
63
|
-
session[:share_token] = params[:share_token] if params.has_key?(:share_token)
|
|
64
|
-
|
|
65
|
-
session[:share_token].presence
|
|
66
|
-
end
|
|
67
|
-
|
|
68
64
|
private
|
|
69
65
|
|
|
70
66
|
def allow_browser(**); end
|
|
@@ -6,6 +6,8 @@ module Decidim
|
|
|
6
6
|
layout false
|
|
7
7
|
|
|
8
8
|
def show
|
|
9
|
+
enforce_permission_to :read, :authorization
|
|
10
|
+
|
|
9
11
|
store_onboarding_cookie_data!(current_user)
|
|
10
12
|
end
|
|
11
13
|
|
|
@@ -23,7 +25,7 @@ module Decidim
|
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def current_component
|
|
26
|
-
@current_component ||= Decidim::Component.where(participatory_space: current_organization.participatory_spaces).find(params[:component_id])
|
|
28
|
+
@current_component ||= Decidim::Component.where(participatory_space: current_organization.participatory_spaces).find(params[:component_id]) # rubocop:disable Decidim/OrganizationScopedFinder -- participatory_spaces is scoped to current_organization
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def authorization_action
|
|
@@ -14,6 +14,8 @@ module Decidim
|
|
|
14
14
|
before_action :check_sign_in_enabled
|
|
15
15
|
|
|
16
16
|
def change_password
|
|
17
|
+
enforce_permission_to(:update, :user, current_user:)
|
|
18
|
+
|
|
17
19
|
self.resource = current_user
|
|
18
20
|
@send_path = apply_password_path
|
|
19
21
|
|
|
@@ -22,6 +24,8 @@ module Decidim
|
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
def apply_password
|
|
27
|
+
enforce_permission_to(:update, :user, current_user:)
|
|
28
|
+
|
|
25
29
|
self.resource = current_user
|
|
26
30
|
@send_path = apply_password_path
|
|
27
31
|
|
|
@@ -43,6 +47,10 @@ module Decidim
|
|
|
43
47
|
|
|
44
48
|
private
|
|
45
49
|
|
|
50
|
+
def user_has_no_permission_path
|
|
51
|
+
new_user_session_path
|
|
52
|
+
end
|
|
53
|
+
|
|
46
54
|
def check_sign_in_enabled
|
|
47
55
|
redirect_to new_user_session_path unless current_organization.sign_in_enabled?
|
|
48
56
|
end
|
|
@@ -6,8 +6,12 @@ module Decidim
|
|
|
6
6
|
class AuthorizationsController < ::Doorkeeper::AuthorizationsController
|
|
7
7
|
include HasSpecificBreadcrumb
|
|
8
8
|
|
|
9
|
+
before_action :set_oauth_application
|
|
10
|
+
|
|
9
11
|
helper_method :oauth_application, :all_abilities?
|
|
10
12
|
|
|
13
|
+
attr_reader :oauth_application
|
|
14
|
+
|
|
11
15
|
def new
|
|
12
16
|
@scopes =
|
|
13
17
|
if pre_auth.authorizable?
|
|
@@ -19,10 +23,6 @@ module Decidim
|
|
|
19
23
|
super
|
|
20
24
|
end
|
|
21
25
|
|
|
22
|
-
def oauth_application
|
|
23
|
-
@oauth_application ||= Decidim::OAuthApplication.find_by(uid: params[:client_id])
|
|
24
|
-
end
|
|
25
|
-
|
|
26
26
|
def breadcrumb_item
|
|
27
27
|
{
|
|
28
28
|
label: t("decidim.doorkeeper.authorizations.new.authorize"),
|
|
@@ -32,6 +32,12 @@ module Decidim
|
|
|
32
32
|
|
|
33
33
|
private
|
|
34
34
|
|
|
35
|
+
def set_oauth_application
|
|
36
|
+
return if params[:client_id].blank?
|
|
37
|
+
|
|
38
|
+
@oauth_application = current_organization.oauth_applications.find_by!(uid: params[:client_id])
|
|
39
|
+
end
|
|
40
|
+
|
|
35
41
|
def all_abilities?
|
|
36
42
|
%w(api:read api:write).all? { |scope| @scopes.include?(scope) } &&
|
|
37
43
|
%w(profile user).any? { |scope| @scopes.include?(scope) }
|
|
@@ -5,6 +5,7 @@ module Decidim
|
|
|
5
5
|
# A controller to expose a simple JSON API so OAuth clients can get the user's information.
|
|
6
6
|
class CredentialsController < ApplicationController
|
|
7
7
|
before_action :doorkeeper_authorize!
|
|
8
|
+
before_action :validate_token_organization!
|
|
8
9
|
respond_to :json
|
|
9
10
|
|
|
10
11
|
def me
|
|
@@ -23,8 +24,12 @@ module Decidim
|
|
|
23
24
|
}
|
|
24
25
|
end
|
|
25
26
|
|
|
27
|
+
def validate_token_organization!
|
|
28
|
+
ensure_in_organization!(doorkeeper_token&.application)
|
|
29
|
+
end
|
|
30
|
+
|
|
26
31
|
def current_resource_owner
|
|
27
|
-
@current_resource_owner ||=
|
|
32
|
+
@current_resource_owner ||= current_organization.users.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
|
|
28
33
|
end
|
|
29
34
|
|
|
30
35
|
def avatar_url
|
|
@@ -12,6 +12,7 @@ module Decidim
|
|
|
12
12
|
class FaviconController < ::DecidimController
|
|
13
13
|
include ActionController::DataStreaming # For Rails 7, check out `ActiveStorage::Streaming`.
|
|
14
14
|
include NeedsOrganization
|
|
15
|
+
include NeedsPermission
|
|
15
16
|
|
|
16
17
|
skip_before_action :verify_authenticity_token, :verify_organization
|
|
17
18
|
skip_after_action :verify_same_origin_request
|
|
@@ -52,5 +53,13 @@ module Decidim
|
|
|
52
53
|
|
|
53
54
|
@favicon_blob ||= current_organization.favicon_ico&.blob
|
|
54
55
|
end
|
|
56
|
+
|
|
57
|
+
def permission_class_chain
|
|
58
|
+
[Decidim::Permissions]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def permission_scope
|
|
62
|
+
:public
|
|
63
|
+
end
|
|
55
64
|
end
|
|
56
65
|
end
|
|
@@ -8,7 +8,7 @@ module Decidim
|
|
|
8
8
|
helper_method :like_button
|
|
9
9
|
# we need to declare with +helper+ to be able to call :render_like_identity from the views
|
|
10
10
|
helper Decidim::LikeableHelper
|
|
11
|
-
helper_method :resource
|
|
11
|
+
helper_method :resource, :current_component
|
|
12
12
|
|
|
13
13
|
before_action :authenticate_user!
|
|
14
14
|
|
|
@@ -4,6 +4,8 @@ module Decidim
|
|
|
4
4
|
# A controller to serve the manifest file for PWA
|
|
5
5
|
class ManifestsController < Decidim::ApplicationController
|
|
6
6
|
def show
|
|
7
|
+
enforce_permission_to :read, :manifest
|
|
8
|
+
|
|
7
9
|
organization_presenter = OrganizationPresenter.new(current_organization)
|
|
8
10
|
render layout: false, locals: { organization_params: organization_presenter }, content_type: "application/manifest+json"
|
|
9
11
|
end
|
|
@@ -43,10 +43,7 @@ module Decidim
|
|
|
43
43
|
|
|
44
44
|
StartConversation.call(@form) do
|
|
45
45
|
on(:ok) do |conversation|
|
|
46
|
-
render action: :create, locals: {
|
|
47
|
-
conversation:,
|
|
48
|
-
form: MessageForm.new
|
|
49
|
-
}
|
|
46
|
+
render action: :create, locals: { conversation: }
|
|
50
47
|
end
|
|
51
48
|
|
|
52
49
|
on(:invalid) do |messages|
|
|
@@ -96,6 +93,15 @@ module Decidim
|
|
|
96
93
|
|
|
97
94
|
def check_multiple
|
|
98
95
|
@form = form(ConversationForm).from_params(params, sender: current_user)
|
|
96
|
+
|
|
97
|
+
conversation = conversation_between_multiple(@form.recipient.to_a.prepend(current_user))
|
|
98
|
+
|
|
99
|
+
if conversation
|
|
100
|
+
enforce_permission_to :read, :conversation, conversation:
|
|
101
|
+
else
|
|
102
|
+
enforce_permission_to :create, :conversation, conversation: new_conversation(@form.recipient)
|
|
103
|
+
end
|
|
104
|
+
|
|
99
105
|
redirect_link = current_or_new_conversation_path_with_multiple(@form.recipient, nickname: params[:nickname])
|
|
100
106
|
redirect_to redirect_link
|
|
101
107
|
end
|
|
@@ -107,7 +113,7 @@ module Decidim
|
|
|
107
113
|
end
|
|
108
114
|
|
|
109
115
|
def conversation
|
|
110
|
-
@conversation ||= Conversation.find(params[:id])
|
|
116
|
+
@conversation ||= Conversation.find(params[:id]) # rubocop:disable Decidim/OrganizationScopedFinder -- conversation permissions require the current user to be a participant
|
|
111
117
|
end
|
|
112
118
|
|
|
113
119
|
def new_conversation(recipient)
|
|
@@ -11,6 +11,8 @@ module Decidim
|
|
|
11
11
|
helper_method :newsletter
|
|
12
12
|
|
|
13
13
|
def show
|
|
14
|
+
enforce_permission_to :read, :newsletter
|
|
15
|
+
|
|
14
16
|
@user = current_user
|
|
15
17
|
@organization = current_organization
|
|
16
18
|
|
|
@@ -20,6 +22,8 @@ module Decidim
|
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
def unsubscribe
|
|
25
|
+
enforce_permission_to :unsubscribe, :newsletter
|
|
26
|
+
|
|
23
27
|
encryptor = Decidim::NewsletterEncryptor
|
|
24
28
|
|
|
25
29
|
decrypted_string = encryptor.sent_at_decrypted(params[:u])
|
|
@@ -6,11 +6,15 @@ module Decidim
|
|
|
6
6
|
rescue_from Decidim::NotificationsSubscriptionsPersistor::UnsupportedPushSubscriptionEndpointError, with: :unsupported_browser
|
|
7
7
|
|
|
8
8
|
def create
|
|
9
|
+
enforce_permission_to(:update, :user, current_user:)
|
|
10
|
+
|
|
9
11
|
Decidim::NotificationsSubscriptionsPersistor.new(current_user).add_subscription(params)
|
|
10
12
|
head :ok
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
def destroy
|
|
16
|
+
enforce_permission_to(:update, :user, current_user:)
|
|
17
|
+
|
|
14
18
|
Decidim::NotificationsSubscriptionsPersistor.new(current_user).delete_subscription(params[:auth])
|
|
15
19
|
head :ok
|
|
16
20
|
end
|
|
@@ -4,9 +4,13 @@ module Decidim
|
|
|
4
4
|
class OpenDataController < Decidim::ApplicationController
|
|
5
5
|
helper_method :open_data_component_manifests, :open_data_participatory_space_manifests, :open_data_core_manifests
|
|
6
6
|
|
|
7
|
-
def index
|
|
7
|
+
def index
|
|
8
|
+
enforce_permission_to :read, :open_data
|
|
9
|
+
end
|
|
8
10
|
|
|
9
11
|
def download
|
|
12
|
+
enforce_permission_to :read, :open_data
|
|
13
|
+
|
|
10
14
|
resource = params[:resource] || nil
|
|
11
15
|
|
|
12
16
|
if open_data_file_for_resource(resource)
|
|
@@ -10,6 +10,10 @@ module Decidim
|
|
|
10
10
|
|
|
11
11
|
before_action :legacy_redirect, :set_default_request_format
|
|
12
12
|
|
|
13
|
+
# Included after the legacy redirect so its before_action does not look the
|
|
14
|
+
# page up (and 404) before the redirect happens.
|
|
15
|
+
include HasSpecificBreadcrumb
|
|
16
|
+
|
|
13
17
|
def index
|
|
14
18
|
enforce_permission_to :read, :public_page
|
|
15
19
|
@topics = StaticPageTopic.where(organization: current_organization)
|
|
@@ -17,14 +21,38 @@ module Decidim
|
|
|
17
21
|
end
|
|
18
22
|
|
|
19
23
|
def show
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@topic =
|
|
24
|
+
enforce_permission_to :read, :public_page, page:
|
|
25
|
+
|
|
26
|
+
@topic = page.topic
|
|
23
27
|
@pages = @topic&.pages
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
private
|
|
27
31
|
|
|
32
|
+
def page
|
|
33
|
+
@page ||= current_organization.static_pages.find_by!(slug: params[:id])
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def breadcrumb_item
|
|
37
|
+
items = [
|
|
38
|
+
{
|
|
39
|
+
label: t("decidim.pages.index.title"),
|
|
40
|
+
active: action_name == "index",
|
|
41
|
+
url: pages_path
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
if action_name == "show"
|
|
46
|
+
items << {
|
|
47
|
+
label: page.title,
|
|
48
|
+
active: true,
|
|
49
|
+
url: page_path(page)
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
items
|
|
54
|
+
end
|
|
55
|
+
|
|
28
56
|
def legacy_redirect
|
|
29
57
|
return redirect_to decidim.page_path("terms-of-service") if params[:id] == "terms-and-conditions"
|
|
30
58
|
end
|
|
@@ -17,28 +17,38 @@ module Decidim
|
|
|
17
17
|
before_action :ensure_user_not_blocked
|
|
18
18
|
|
|
19
19
|
def show
|
|
20
|
+
enforce_permission_to :read, :profile
|
|
21
|
+
|
|
20
22
|
redirect_to profile_activity_path(nickname: params[:nickname].downcase)
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def following
|
|
26
|
+
enforce_permission_to :read, :profile
|
|
27
|
+
|
|
24
28
|
@content_cell = "decidim/following"
|
|
25
29
|
@title_key = "following"
|
|
26
30
|
render :show
|
|
27
31
|
end
|
|
28
32
|
|
|
29
33
|
def followers
|
|
34
|
+
enforce_permission_to :read, :profile
|
|
35
|
+
|
|
30
36
|
@content_cell = "decidim/followers"
|
|
31
37
|
@title_key = "followers"
|
|
32
38
|
render :show
|
|
33
39
|
end
|
|
34
40
|
|
|
35
41
|
def badges
|
|
42
|
+
enforce_permission_to :read, :profile
|
|
43
|
+
|
|
36
44
|
@content_cell = "decidim/badges"
|
|
37
45
|
@title_key = "badges"
|
|
38
46
|
render :show
|
|
39
47
|
end
|
|
40
48
|
|
|
41
49
|
def activity
|
|
50
|
+
enforce_permission_to :read, :profile
|
|
51
|
+
|
|
42
52
|
@content_cell = "decidim/user_activity"
|
|
43
53
|
@title_key = "activity"
|
|
44
54
|
render :show
|
|
@@ -61,7 +71,7 @@ module Decidim
|
|
|
61
71
|
def profile_holder
|
|
62
72
|
return if params[:nickname].blank?
|
|
63
73
|
|
|
64
|
-
@profile_holder ||=
|
|
74
|
+
@profile_holder ||= current_organization.user_entities.find_by(nickname: params[:nickname].downcase)
|
|
65
75
|
end
|
|
66
76
|
end
|
|
67
77
|
end
|
|
@@ -7,7 +7,7 @@ module Decidim
|
|
|
7
7
|
include Decidim::OrganizationHelper
|
|
8
8
|
include Decidim::QrCodeHelper
|
|
9
9
|
|
|
10
|
-
helper_method :resource, :qr_code, :qr_code_image
|
|
10
|
+
helper_method :resource, :qr_code, :qr_code_image, :current_component, :current_participatory_space
|
|
11
11
|
before_action :validate_resource
|
|
12
12
|
before_action :validate_component
|
|
13
13
|
before_action :validate_participatory_space
|
|
@@ -15,6 +15,8 @@ module Decidim
|
|
|
15
15
|
layout false
|
|
16
16
|
|
|
17
17
|
def show
|
|
18
|
+
enforce_permission_to :read, :qr_code
|
|
19
|
+
|
|
18
20
|
respond_to do |format|
|
|
19
21
|
format.html
|
|
20
22
|
format.png { send_data(qr_code.as_png(size: 500), filename: "qr-#{organization_name}-#{parametrized_title}.png") }
|